Skip to content

Commit

Permalink
#5108: Remove superfluous leading slash when traversing a directory i…
Browse files Browse the repository at this point in the history
…n the file system. Add unit test covering that.
  • Loading branch information
codereader committed Nov 20, 2020
1 parent a12489e commit 5fd0dcb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion radiantcore/vfs/Doom3FileSystem.cpp
Expand Up @@ -301,7 +301,7 @@ void Doom3FileSystem::forEachFileInAbsolutePath(const std::string& path,
// Construct our FileVisitor filtering out the right elements
FileVisitor fileVisitor(visitorFunc, "", extension, depth);

tempArchive.traverse(fileVisitor, "/");
tempArchive.traverse(fileVisitor, "");
}

void Doom3FileSystem::forEachFileInArchive(const std::string& absoluteArchivePath,
Expand Down
15 changes: 15 additions & 0 deletions test/VFS.cpp
Expand Up @@ -188,4 +188,19 @@ TEST_F(VfsTest, VisitEachFileInArchive)
EXPECT_EQ(foundFiles.count("materials/tdm_bloom_afx.mtr"), 1);
}

TEST_F(VfsTest, VisitEachFileInAbsolutePath)
{
// Use a visitor to walk the tree
std::set<std::string> foundFiles;
GlobalFileSystem().forEachFileInAbsolutePath(
_context.getTestResourcePath(), "*",
[&](const vfs::FileInfo& fi) { foundFiles.insert(fi.name); },
0
);

EXPECT_EQ(foundFiles.count("tdm_example_mtrs.pk4"), 1);
EXPECT_EQ(foundFiles.count("models/moss_patch.ase"), 1);
EXPECT_EQ(foundFiles.count("materials/___NONEXISTENTFILE.mtr"), 0);
}

}

0 comments on commit 5fd0dcb

Please sign in to comment.