Skip to content

Commit

Permalink
DirectoryTree: Fix finding files when the path component is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghabry committed Nov 16, 2021
1 parent 47346b3 commit 8de4c7d
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/directory_tree.cpp
Expand Up @@ -73,24 +73,22 @@ DirectoryTree::DirectoryListType* DirectoryTree::ListDirectory(StringView path)
std::string parent_dir, child_dir;
std::tie(parent_dir, child_dir) = FileFinder::GetPathAndFilename(fs_path);

if (!parent_dir.empty()) {
// Go up and determine the proper casing of the folder
auto* parent_tree = ListDirectory(parent_dir);
if (!parent_tree) {
return nullptr;
}
// Go up and determine the proper casing of the folder
auto* parent_tree = ListDirectory(parent_dir);
if (!parent_tree) {
return nullptr;
}

auto parent_key = make_key(parent_dir);
auto parent_it = dir_cache.find(parent_key);
assert(parent_it != dir_cache.end());
auto parent_key = make_key(parent_dir);
auto parent_it = dir_cache.find(parent_key);
assert(parent_it != dir_cache.end());

auto child_key = make_key(child_dir);
auto child_it = parent_tree->find(child_key);
if (child_it != parent_tree->end()) {
fs_path = FileFinder::MakePath(parent_it->second, child_it->second.name);
} else {
return nullptr;
}
auto child_key = make_key(child_dir);
auto child_it = parent_tree->find(child_key);
if (child_it != parent_tree->end()) {
fs_path = FileFinder::MakePath(parent_it->second, child_it->second.name);
} else {
return nullptr;
}
}

Expand Down

0 comments on commit 8de4c7d

Please sign in to comment.