improve duplicate file detection in torrent files

This commit is contained in:
Arvid Norberg
2013-11-18 06:59:47 +00:00
parent 31ecd1b914
commit bcb703b9a3
5 changed files with 35 additions and 8 deletions

View File

@@ -127,6 +127,11 @@ int test_main()
TEST_EQUAL(extension("blah.foo."), ".");
TEST_EQUAL(extension("blah.foo/bar"), "");
TEST_EQUAL(remove_extension("blah"), "blah");
TEST_EQUAL(remove_extension("blah.exe"), "blah");
TEST_EQUAL(remove_extension("blah.foo.bar"), "blah.foo");
TEST_EQUAL(remove_extension("blah.foo."), "blah.foo");
TEST_EQUAL(filename("blah"), "blah");
TEST_EQUAL(filename("/blah/foo/bar"), "bar");
TEST_EQUAL(filename("/blah/foo/bar/"), "bar");

View File

@@ -41,7 +41,6 @@ int test_main()
{
file_storage fs;
int total_size = 100 * 0x4000;
fs.add_file("test/temporary.txt", 0x4000);
fs.add_file("test/A/tmp", 0x4000);
@@ -76,12 +75,17 @@ int test_main()
"test/A/tmp",
"test/Temporary.1.txt", // duplicate of temporary.txt
"test/TeMPorArY.2.txT", // duplicate of temporary.txt
"test/a.1", // a file may not have the same name as a directory
// a file may not have the same name as a directory
// however, detecting this is not supported currently.
// it is in the next major release
"test/a",
"test/b.exe",
"test/B.1.ExE", // duplicate of b.exe
"test/B.2.exe", // duplicate of b.exe
"test/test/TEMPORARY.TXT", // a file with the same name in a seprate directory is fine
"test/A.2", // duplicate of directory a
"test/A.1", // duplicate of directory a
};
for (int i = 0; i < ti.num_files(); ++i)