diff options
author | Johannes Schickel | 2016-02-26 14:38:28 +0100 |
---|---|---|
committer | Johannes Schickel | 2016-02-26 14:38:28 +0100 |
commit | aa369ab48fba04f3315bff5fe3ecd300b7d75373 (patch) | |
tree | 3f916ddb8e4ca4427d2c62dbe9a3af71b34d6bf9 | |
parent | 73fa24cae076afd021a8cba4bf79094524bd5d4b (diff) | |
parent | 587d5d570310118595140b475d77a4be9999963d (diff) | |
download | scummvm-rg350-aa369ab48fba04f3315bff5fe3ecd300b7d75373.tar.gz scummvm-rg350-aa369ab48fba04f3315bff5fe3ecd300b7d75373.tar.bz2 scummvm-rg350-aa369ab48fba04f3315bff5fe3ecd300b7d75373.zip |
Merge pull request #684 from bSr43/master
IOS: Fixes savegame deletion on sandboxed iOS devices
-rw-r--r-- | backends/platform/ios7/ios7_osys_main.cpp | 32 | ||||
-rw-r--r-- | backends/platform/ios7/ios7_osys_main.h | 4 |
2 files changed, 34 insertions, 2 deletions
diff --git a/backends/platform/ios7/ios7_osys_main.cpp b/backends/platform/ios7/ios7_osys_main.cpp index c1280a2969..25d9cbed15 100644 --- a/backends/platform/ios7/ios7_osys_main.cpp +++ b/backends/platform/ios7/ios7_osys_main.cpp @@ -79,6 +79,33 @@ AQCallbackStruct OSystem_iOS7::s_AudioQueue; SoundProc OSystem_iOS7::s_soundCallback = NULL; void *OSystem_iOS7::s_soundParam = NULL; +#ifdef IPHONE_SANDBOXED +class SandboxedSaveFileManager : public DefaultSaveFileManager { + Common::String _sandboxRootPath; +public: + + SandboxedSaveFileManager(Common::String sandboxRootPath, Common::String defaultSavepath) + : DefaultSaveFileManager(defaultSavepath), _sandboxRootPath(sandboxRootPath) { + } + + virtual bool removeSavefile(const Common::String &filename) override { + Common::String chrootedFile = getSavePath() + "/" + filename; + Common::String realFilePath = _sandboxRootPath + chrootedFile; + + if (remove(realFilePath.c_str()) != 0) { + if (errno == EACCES) + setError(Common::kWritePermissionDenied, "Search or write permission denied: "+chrootedFile); + + if (errno == ENOENT) + setError(Common::kPathDoesNotExist, "removeSavefile: '"+chrootedFile+"' does not exist or path is invalid"); + return false; + } else { + return true; + } + } +}; +#endif + OSystem_iOS7::OSystem_iOS7() : _mixer(NULL), _lastMouseTap(0), _queuedEventTime(0), _mouseNeedTextureUpdate(false), _secondaryTapped(false), _lastSecondaryTap(0), @@ -89,7 +116,8 @@ OSystem_iOS7::OSystem_iOS7() : _queuedInputEvent.type = Common::EVENT_INVALID; _touchpadModeEnabled = !iOS7_isBigDevice(); #ifdef IPHONE_SANDBOXED - _fsFactory = new ChRootFilesystemFactory(iOS7_getDocumentsDir()); + _chrootBasePath = iOS7_getDocumentsDir(); + _fsFactory = new ChRootFilesystemFactory(_chrootBasePath); #else _fsFactory = new POSIXFilesystemFactory(); #endif @@ -124,7 +152,7 @@ int OSystem_iOS7::timerHandler(int t) { void OSystem_iOS7::initBackend() { #ifdef IPHONE_SANDBOXED - _savefileManager = new DefaultSaveFileManager("/Savegames"); + _savefileManager = new SandboxedSaveFileManager(_chrootBasePath, "/Savegames"); #else _savefileManager = new DefaultSaveFileManager(SCUMMVM_SAVE_PATH); #endif diff --git a/backends/platform/ios7/ios7_osys_main.h b/backends/platform/ios7/ios7_osys_main.h index cc2f1ccc06..174c160bd6 100644 --- a/backends/platform/ios7/ios7_osys_main.h +++ b/backends/platform/ios7/ios7_osys_main.h @@ -111,6 +111,10 @@ protected: char *_lastErrorMessage; +#ifdef IPHONE_SANDBOXED + Common::String _chrootBasePath; +#endif + public: OSystem_iOS7(); |