summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinTool/ExtractCommand.cpp
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2024-07-23 19:56:07 +0200
committerGitHub <noreply@github.com>2024-07-23 19:56:07 +0200
commit7db5caf43e85362aacb47fd4c5383ddaed31b052 (patch)
tree962b5bffe51c5a78d20e2d2de27a59c41d38d857 /Source/Core/DolphinTool/ExtractCommand.cpp
parent933da0788d8087c365c0ed9ac12c45e85216ce6e (diff)
parent191b36976cd36d1edfe8a022c1c2e0046687a83b (diff)
Merge pull request #12943 from Tilka/list_recursively
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;
}