Add an iOS-only utility in devtools to copy savestates to memstick root.

Makes it easier to access the files on iOS over USB from MacOS.
This commit is contained in:
Henrik Rydgård 2020-12-16 00:06:39 +01:00
parent 1814fa5602
commit ed9c54b93a
4 changed files with 29 additions and 1 deletions

View file

@ -608,6 +608,8 @@ std::string GetSysDirectory(PSPDirectories directoryType) {
return g_Config.memStickDirectory + "PSP/VIDEO/";
case DIRECTORY_AUDIO:
return g_Config.memStickDirectory + "PSP/AUDIO/";
case DIRECTORY_MEMSTICK_ROOT:
return g_Config.memStickDirectory;
// Just return the memory stick root if we run into some sort of problem.
default:
ERROR_LOG(FILESYS, "Unknown directory type.");

View file

@ -49,7 +49,8 @@ enum PSPDirectories {
DIRECTORY_PLUGINS,
DIRECTORY_APP_CACHE, // Use the OS app cache if available
DIRECTORY_VIDEO,
DIRECTORY_AUDIO
DIRECTORY_AUDIO,
DIRECTORY_MEMSTICK_ROOT,
};
class GraphicsContext;

View file

@ -1661,6 +1661,12 @@ void DeveloperToolsScreen::CreateViews() {
list->Add(new CheckBox(&g_Config.bSaveNewTextures, dev->T("Save new textures")));
list->Add(new CheckBox(&g_Config.bReplaceTextures, dev->T("Replace textures")));
// Makes it easy to get savestates out of an iOS device. The file listing shown in MacOS doesn't allow
// you to descend into directories.
#if PPSSPP_PLATFORM(IOS)
list->Add(new Choice(dev->T("Copy savestates to memstick root")))->OnClick.Handle(this, &DeveloperToolsScreen::OnCopyStatesToRoot);
#endif
#if !defined(MOBILE_DEVICE)
Choice *createTextureIni = list->Add(new Choice(dev->T("Create/Open textures.ini file for current game")));
createTextureIni->OnClick.Handle(this, &DeveloperToolsScreen::OnOpenTexturesIniFile);
@ -1755,6 +1761,24 @@ UI::EventReturn DeveloperToolsScreen::OnJitAffectingSetting(UI::EventParams &e)
return UI::EVENT_DONE;
}
UI::EventReturn DeveloperToolsScreen::OnCopyStatesToRoot(UI::EventParams &e) {
std::string savestate_dir = GetSysDirectory(DIRECTORY_SAVESTATE);
std::string root_dir = GetSysDirectory(DIRECTORY_MEMSTICK_ROOT);
std::vector<FileInfo> files;
getFilesInDir(savestate_dir.c_str(), &files, nullptr, 0);
for (const FileInfo &file : files) {
std::string src = file.fullName;
std::string dst = root_dir + file.name;
INFO_LOG(SYSTEM, "Copying file '%s' to '%s'", src.c_str(), dst.c_str());
File::Copy(src, dst);
}
return UI::EVENT_DONE;
}
UI::EventReturn DeveloperToolsScreen::OnRemoteDebugger(UI::EventParams &e) {
if (allowDebugger_) {
StartWebServer(WebServerFlags::DEBUGGER);

View file

@ -179,6 +179,7 @@ private:
UI::EventReturn OnRemoteDebugger(UI::EventParams &e);
UI::EventReturn OnGPUDriverTest(UI::EventParams &e);
UI::EventReturn OnTouchscreenTest(UI::EventParams &e);
UI::EventReturn OnCopyStatesToRoot(UI::EventParams &e);
bool allowDebugger_ = false;
bool canAllowDebugger_ = true;