summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/yuzu/main.cpp84
1 files changed, 42 insertions, 42 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 1455edc89..1b125cbd3 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -756,6 +756,46 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target
QDesktopServices::openUrl(QUrl::fromLocalFile(qpath));
}
+static std::size_t CalculateRomFSEntrySize(const FileSys::VirtualDir& dir, bool full) {
+ std::size_t out = 0;
+
+ for (const auto& subdir : dir->GetSubdirectories()) {
+ out += 1 + CalculateRomFSEntrySize(subdir, full);
+ }
+
+ return out + full ? dir->GetFiles().size() : 0;
+}
+
+static bool RomFSRawCopy(QProgressDialog& dialog, const FileSys::VirtualDir& src,
+ const FileSys::VirtualDir& dest, std::size_t block_size, bool full) {
+ if (src == nullptr || dest == nullptr || !src->IsReadable() || !dest->IsWritable())
+ return false;
+ if (dialog.wasCanceled())
+ return false;
+
+ if (full) {
+ for (const auto& file : src->GetFiles()) {
+ const auto out = VfsDirectoryCreateFileWrapper(dest, file->GetName());
+ if (!FileSys::VfsRawCopy(file, out, block_size))
+ return false;
+ dialog.setValue(dialog.value() + 1);
+ if (dialog.wasCanceled())
+ return false;
+ }
+ }
+
+ for (const auto& dir : src->GetSubdirectories()) {
+ const auto out = dest->CreateSubdirectory(dir->GetName());
+ if (!RomFSRawCopy(dialog, dir, out, block_size, full))
+ return false;
+ dialog.setValue(dialog.value() + 1);
+ if (dialog.wasCanceled())
+ return false;
+ }
+
+ return true;
+}
+
void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_path) {
const auto path = fmt::format("{}{:016X}/romfs",
FileUtil::GetUserPath(FileUtil::UserPath::DumpDir), program_id);
@@ -808,53 +848,13 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa
failed();
const auto full = res == "Full";
-
- static const std::function<std::size_t(const FileSys::VirtualDir&, bool)> calculate_entry_size =
- [](const FileSys::VirtualDir& dir, bool full) {
- std::size_t out = 0;
- for (const auto& subdir : dir->GetSubdirectories())
- out += 1 + calculate_entry_size(subdir, full);
- return out + full ? dir->GetFiles().size() : 0;
- };
- const auto entry_size = calculate_entry_size(extracted, full);
+ const auto entry_size = CalculateRomFSEntrySize(extracted, full);
QProgressDialog progress(tr("Extracting RomFS..."), tr("Cancel"), 0, entry_size, this);
progress.setWindowModality(Qt::WindowModal);
progress.setMinimumDuration(100);
- static const std::function<bool(QProgressDialog&, const FileSys::VirtualDir&,
- const FileSys::VirtualDir&, std::size_t, bool)>
- qt_raw_copy = [](QProgressDialog& dialog, const FileSys::VirtualDir& src,
- const FileSys::VirtualDir& dest, std::size_t block_size, bool full) {
- if (src == nullptr || dest == nullptr || !src->IsReadable() || !dest->IsWritable())
- return false;
- if (dialog.wasCanceled())
- return false;
-
- if (full) {
- for (const auto& file : src->GetFiles()) {
- const auto out = VfsDirectoryCreateFileWrapper(dest, file->GetName());
- if (!FileSys::VfsRawCopy(file, out, block_size))
- return false;
- dialog.setValue(dialog.value() + 1);
- if (dialog.wasCanceled())
- return false;
- }
- }
-
- for (const auto& dir : src->GetSubdirectories()) {
- const auto out = dest->CreateSubdirectory(dir->GetName());
- if (!qt_raw_copy(dialog, dir, out, block_size, full))
- return false;
- dialog.setValue(dialog.value() + 1);
- if (dialog.wasCanceled())
- return false;
- }
-
- return true;
- };
-
- if (qt_raw_copy(progress, extracted, out, 0x400000, full)) {
+ if (RomFSRawCopy(progress, extracted, out, 0x400000, full)) {
progress.close();
QMessageBox::information(this, tr("RomFS Extraction Succeeded!"),
tr("The operation completed successfully."));