diff options
| author | JosJuice <josjuice@gmail.com> | 2017-06-18 13:20:54 +0200 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2017-06-28 22:22:31 +0200 |
| commit | 6d5199264895f007b9714d448519f5fafec00fa6 (patch) | |
| tree | 411de8bdd97dd4126185ac70fa09452a535b5897 /Source/Core/DiscIO/DiscExtractor.cpp | |
| parent | 5778e8bdba204a1c571eeaf958250f5afcfd8610 (diff) | |
Move ExtractDir from FilesystemPanel to DiscExtractor
Diffstat (limited to 'Source/Core/DiscIO/DiscExtractor.cpp')
| -rw-r--r-- | Source/Core/DiscIO/DiscExtractor.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Source/Core/DiscIO/DiscExtractor.cpp b/Source/Core/DiscIO/DiscExtractor.cpp index 323fe706f2..dbd5a7a821 100644 --- a/Source/Core/DiscIO/DiscExtractor.cpp +++ b/Source/Core/DiscIO/DiscExtractor.cpp @@ -71,6 +71,38 @@ bool ExportFile(const Volume& volume, const Partition& partition, const FileInfo export_filename); } +void ExportDirectory(const Volume& volume, const Partition partition, const FileInfo& directory, + bool recursive, const std::string& filesystem_path, + const std::string& export_folder, + const std::function<bool(const std::string& path)>& update_progress) +{ + for (const FileInfo& file_info : directory) + { + const std::string path = + filesystem_path + file_info.GetName() + (file_info.IsDirectory() ? "/" : ""); + const std::string export_path = export_folder + '/' + path; + + if (update_progress(path)) + return; + + DEBUG_LOG(DISCIO, "%s", export_path.c_str()); + + if (!file_info.IsDirectory()) + { + if (File::Exists(export_path)) + NOTICE_LOG(DISCIO, "%s already exists", export_path.c_str()); + else if (!ExportFile(volume, partition, &file_info, export_path)) + ERROR_LOG(DISCIO, "Could not export %s", export_path.c_str()); + } + else if (recursive) + { + File::CreateFullPath(export_path); + ExportDirectory(volume, partition, file_info, recursive, path, export_folder, + update_progress); + } + } +} + bool ExportApploader(const Volume& volume, const Partition& partition, const std::string& export_filename) { |
