summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinTool/ExtractCommand.cpp
diff options
context:
space:
mode:
authorTillmann Karras <tilkax@gmail.com>2024-07-21 05:29:20 +0100
committerTillmann Karras <tilkax@gmail.com>2024-07-21 19:16:00 +0100
commit191b36976cd36d1edfe8a022c1c2e0046687a83b (patch)
tree9725bee1aed037b1c832722e8d7a4bd06f6346bb /Source/Core/DolphinTool/ExtractCommand.cpp
parent7bd2a7bde301c9dc255ae45e60fcfcd8ba10aecc (diff)
DolphinTool: list filesystem recursively
Diffstat (limited to 'Source/Core/DolphinTool/ExtractCommand.cpp')
-rw-r--r--Source/Core/DolphinTool/ExtractCommand.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/Source/Core/DolphinTool/ExtractCommand.cpp b/Source/Core/DolphinTool/ExtractCommand.cpp
index 1dfe849869..d1daa3dd07 100644
--- a/Source/Core/DolphinTool/ExtractCommand.cpp
+++ b/Source/Core/DolphinTool/ExtractCommand.cpp
@@ -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;
}