From e6330a58f482765a06952d88ab612ccde07a67ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 25 Sep 2026 15:34:47 -0600 Subject: [PATCH] Headless: --dump-file lists a directory when given one Co-Authored-By: Claude Opus 5.5 (1M context) --- Core/CmdLine.cpp | 2 +- headless/ReverseEngineer.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Core/CmdLine.cpp b/Core/CmdLine.cpp index cb2aef5662..b411262384 100644 --- a/Core/CmdLine.cpp +++ b/Core/CmdLine.cpp @@ -224,7 +224,7 @@ static const CommandLineParam g_autoParams[] = { {POFF(reRawBase), CmdParamType::String, "re-raw-base", '\0', "Treat --re-module as a raw code image loaded at this address, e.g. 0x08300000", CmdLineMode::Headless}, {POFF(reDecrypt), CmdParamType::String, "re-decrypt", '\0', "Decrypt one encrypted PSP file (PRX or ME image) and exit", CmdLineMode::Headless}, {POFF(reDecryptOut), CmdParamType::String, "re-decrypt-out", '\0', "Output file for --re-decrypt (default: decrypted.bin)", CmdLineMode::Headless}, - {POFF(dumpFile), CmdParamType::String, "dump-file", '\0', "Copy one file out of the disc image, e.g. disc0:/PSP_GAME/USRDIR/MOVIE.PMF, and exit", CmdLineMode::Headless}, + {POFF(dumpFile), CmdParamType::String, "dump-file", '\0', "Copy one file out of the disc image, e.g. disc0:/PSP_GAME/USRDIR/MOVIE.PMF, or list a directory, and exit", CmdLineMode::Headless}, {POFF(dumpFileOut), CmdParamType::String, "dump-file-out", '\0', "Output file for --dump-file (default: the file's own name)", CmdLineMode::Headless}, {POFF(odsLog), CmdParamType::Bool, "odslog", 'o', "Also log through OutputDebugString (Windows)", CmdLineMode::Headless}, {POFF(generateInterpreterDispatch), CmdParamType::Bool, "generate-interpreter-dispatch", '\0', "Generate C++ interpreter dispatch code (ExecInstruction) to stdout and exit", CmdLineMode::Headless}, diff --git a/headless/ReverseEngineer.cpp b/headless/ReverseEngineer.cpp index 0ff22333b8..fa3ab9f19a 100644 --- a/headless/ReverseEngineer.cpp +++ b/headless/ReverseEngineer.cpp @@ -414,6 +414,15 @@ int RunDumpDiscFile(const std::string &discPath, const std::string &inPath, cons loader.release(); ISOFileSystem isoFs(&pspFileSystem, device); + // A directory gets listed instead. + const PSPFileInfo dirInfo = isoFs.GetFileInfo(insideDisc); + if (dirInfo.exists && dirInfo.type == FILETYPE_DIRECTORY) { + for (const PSPFileInfo &entry : isoFs.GetDirListing(insideDisc)) { + printf("%s %10lld %s\n", entry.type == FILETYPE_DIRECTORY ? "d" : "-", (long long)entry.size, entry.name.c_str()); + } + return 0; + } + const int handle = isoFs.OpenFile(insideDisc, FILEACCESS_READ); if (handle < 0) { fprintf(stderr, "dump-file: no such file on the disc: %s\n", insideDisc.c_str());