Fix dumping

This commit is contained in:
wheremyfoodat 2023-10-07 21:52:47 +03:00
parent abe4675477
commit ab2ff18290
2 changed files with 18 additions and 18 deletions

View file

@ -583,24 +583,25 @@ void Emulator::updateDiscord() {
void Emulator::updateDiscord() {} void Emulator::updateDiscord() {}
#endif #endif
static void printNode(const RomFS::RomFSNode& node, int indentation) { static void printNode(const RomFS::RomFSNode& node, const char* romFSBase, const std::filesystem::path& path) {
for (int i = 0; i < indentation; i++) {
printf(" ");
}
printf("%s/\n", std::string(node.name.begin(), node.name.end()).c_str());
for (auto& file : node.files) { for (auto& file : node.files) {
for (int i = 0; i <= indentation; i++) { const auto p = path / file->name;
printf(" "); std::ofstream outFile(p);
}
printf("%s\n", std::string(file->name.begin(), file->name.end()).c_str()); outFile.write(romFSBase + file->dataOffset, file->dataSize);
} }
indentation++;
for (auto& directory : node.directories) { for (auto& directory : node.directories) {
printNode(*directory, indentation); const auto newPath = path / directory->name;
// Create the directory for the new folder
std::error_code ec;
std::filesystem::create_directories(newPath, ec);
if (!ec) {
printNode(*directory, romFSBase, newPath);
}
} }
indentation--;
} }
RomFS::DumpingResult Emulator::dumpRomFS(const std::filesystem::path& path) { RomFS::DumpingResult Emulator::dumpRomFS(const std::filesystem::path& path) {
@ -637,7 +638,7 @@ RomFS::DumpingResult Emulator::dumpRomFS(const std::filesystem::path& path) {
} }
std::unique_ptr<RomFSNode> node = parseRomFSTree((uintptr_t)&romFS[0], size); std::unique_ptr<RomFSNode> node = parseRomFSTree((uintptr_t)&romFS[0], size);
printNode(*node, 0); printNode(*node, (const char*) &romFS[0], path);
return DumpingResult::Success; return DumpingResult::Success;
} }

View file

@ -77,7 +77,6 @@ void MainWindow::emuThreadMainLoop() {
} }
needToLoadROM.store(false, std::memory_order::seq_cst); needToLoadROM.store(false, std::memory_order::seq_cst);
emu->dumpRomFS("");
} }
emu->runFrame(); emu->runFrame();
@ -105,8 +104,8 @@ void MainWindow::selectROM() {
return; return;
} }
auto path = QFileDialog::getOpenFileName( auto path =
this, tr("Select 3DS ROM to load"), {}, tr("Nintendo 3DS ROMs (*.3ds *.cci *.cxi *.app *.3dsx *.elf *.axf)"), {}); QFileDialog::getOpenFileName(this, tr("Select 3DS ROM to load"), "", tr("Nintendo 3DS ROMs (*.3ds *.cci *.cxi *.app *.3dsx *.elf *.axf)"));
if (!path.isEmpty()) { if (!path.isEmpty()) {
romToLoad = path.toStdU16String(); romToLoad = path.toStdU16String();
@ -195,5 +194,5 @@ void MainWindow::dumpRomFS() {
} }
std::filesystem::path path(folder.toStdU16String()); std::filesystem::path path(folder.toStdU16String());
//RomFS::DumpingResult res = emu->dumpRomFS(path); RomFS::DumpingResult res = emu->dumpRomFS(path);
} }