Merge pull request #12943 from Tilka/list_recursively

DolphinTool: list filesystem recursively
This commit is contained in:
Admiral H. Curtiss 2024-07-23 19:56:07 +02:00 committed by GitHub
commit 7db5caf43e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -97,6 +97,25 @@ static void ExtractPartition(const DiscIO::Volume& disc_volume, const DiscIO::Pa
ExtractSystemData(disc_volume, partition, out);
}
static void ListRecursively(const std::string& path, const DiscIO::FileInfo& info,
std::string* result_text)
{
// Don't print the root.
if (!path.empty())
{
const std::string line = fmt::format("{}\n", path);
fmt::print("{}", line);
result_text->append(line);
}
for (const DiscIO::FileInfo& child_info : info)
{
std::string child_path = path + child_info.GetName();
if (child_info.IsDirectory())
child_path += '/';
ListRecursively(child_path, child_info, result_text);
}
}
static bool ListPartition(const DiscIO::Volume& disc_volume, const DiscIO::Partition& partition,
const std::string& partition_name, const std::string& path,
std::string* result_text)
@ -113,12 +132,8 @@ static bool ListPartition(const DiscIO::Volume& disc_volume, const DiscIO::Parti
return false;
}
for (auto it = info->begin(); it != info->end(); ++it)
{
const std::string file_name = fmt::format("{}\n", it->GetName());
fmt::print(std::cout, "{}", file_name);
result_text->append(file_name);
}
// Canonicalize user-provided path by reconstructing it using GetPath().
ListRecursively(info->GetPath(), *info, result_text);
return true;
}