Add a simple extract file command.

Mostly useful for quickly/easily extracting pmf/atrac/etc. files.
This commit is contained in:
Unknown W. Brackets committed 2014-01-01 16:47:15 -08:00
1 parent b8a5eb47b6
commit 2618f2ed39
4 files changed
+39 -3

No files matched your search

+34
View File
@@ -35,6 +35,7 @@
#include "util/text/utf8.h"
#include "Core/Debugger/SymbolMap.h"
#include "Windows/InputBox.h"
#include "Windows/OpenGLBase.h"
#include "Windows/Debugger/Debugger_Disasm.h"
#include "Windows/Debugger/Debugger_MemoryDlg.h"
@@ -48,6 +49,7 @@
#include "Core/Config.h"
#include "Core/MIPS/JitCommon/JitCommon.h"
#include "Core/MIPS/JitCommon/JitBlockCache.h"
#include "Core/FileSystems/MetaFileSystem.h"
#include "Windows/EmuThread.h"
#include "resource.h"
@@ -1389,6 +1391,38 @@ namespace MainWindow
memoryWindow[0]->Show(true);
break;
case ID_DEBUG_EXTRACTFILE:
{
std::string filename;
if (!InputBox_GetString(hInst, hwndMain, L"Disc filename", filename, filename)) {
break;
}
const char *lastSlash = strrchr(filename.c_str(), '/');
if (lastSlash) {
fn = lastSlash + 1;
} else {
fn = "";
}
PSPFileInfo info = pspFileSystem.GetFileInfo(filename);
if (!info.exists) {
MessageBox(hwndMain, L"File does not exist.", L"Sorry",0);
} else if (info.type == FILETYPE_DIRECTORY) {
MessageBox(hwndMain, L"Cannot extract directories.", L"Sorry",0);
} else if (W32Util::BrowseForFileName(false, hWnd, L"Save file as...", 0, L"0All files\0*.*\0\0", L"", fn)) {
FILE *fp = fopen(fn.c_str(), "wb");
u32 handle = pspFileSystem.OpenFile(filename, FILEACCESS_READ, "");
u8 buffer[4096];
while (pspFileSystem.ReadFile(handle, buffer, sizeof(buffer)) > 0) {
fwrite(buffer, sizeof(buffer), 1, fp);
}
pspFileSystem.CloseFile(handle);
fclose(fp);
}
}
break;
case ID_DEBUG_LOG:
LogManager::GetInstance()->GetConsoleListener()->Show(LogManager::GetInstance()->GetConsoleListener()->Hidden());
break;