ANDROID: Don't directly use remove() for save files
Use our brand new remove feature in filesystem
This commit is contained in:
parent
075c3f4246
commit
2c089c4ed3
1 changed files with 34 additions and 3 deletions
|
@ -70,6 +70,7 @@
|
||||||
#include "backends/graphics3d/android/android-graphics3d.h"
|
#include "backends/graphics3d/android/android-graphics3d.h"
|
||||||
#include "backends/platform/android/jni-android.h"
|
#include "backends/platform/android/jni-android.h"
|
||||||
#include "backends/platform/android/android.h"
|
#include "backends/platform/android/android.h"
|
||||||
|
#include "backends/fs/android/android-fs.h"
|
||||||
#include "backends/fs/android/android-fs-factory.h"
|
#include "backends/fs/android/android-fs-factory.h"
|
||||||
|
|
||||||
const char *android_log_tag = "ScummVM";
|
const char *android_log_tag = "ScummVM";
|
||||||
|
@ -122,6 +123,38 @@ void checkGlError(const char *expr, const char *file, int line) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
class AndroidSaveFileManager : public DefaultSaveFileManager {
|
||||||
|
public:
|
||||||
|
AndroidSaveFileManager(const Common::String &defaultSavepath) : DefaultSaveFileManager(defaultSavepath) {}
|
||||||
|
|
||||||
|
bool removeSavefile(const Common::String &filename) override {
|
||||||
|
Common::String path = getSavePath() + "/" + filename;
|
||||||
|
AbstractFSNode *node = AndroidFilesystemFactory::instance().makeFileNodePath(path);
|
||||||
|
|
||||||
|
if (!node) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
AndroidFSNode *anode = dynamic_cast<AndroidFSNode *>(node);
|
||||||
|
|
||||||
|
if (!anode) {
|
||||||
|
// This should never happen
|
||||||
|
warning("Invalid node received");
|
||||||
|
delete node;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ret = anode->remove();
|
||||||
|
|
||||||
|
delete anode;
|
||||||
|
|
||||||
|
if (!ret) {
|
||||||
|
setError(Common::kUnknownError, Common::String("Couldn't delete the save file: %s", path.c_str()));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) :
|
OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) :
|
||||||
_audio_sample_rate(audio_sample_rate),
|
_audio_sample_rate(audio_sample_rate),
|
||||||
_audio_buffer_size(audio_buffer_size),
|
_audio_buffer_size(audio_buffer_size),
|
||||||
|
@ -450,9 +483,7 @@ void OSystem_Android::initBackend() {
|
||||||
ConfMan.setInt("gui_scale", 125); // "Large" (see gui/options.cpp and guiBaseValues[])
|
ConfMan.setInt("gui_scale", 125); // "Large" (see gui/options.cpp and guiBaseValues[])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_savefileManager = new AndroidSaveFileManager(ConfMan.get("path") + "/saves");
|
||||||
ConfMan.registerDefault("savepath", ConfMan.get("path") + "/saves");
|
|
||||||
_savefileManager = new DefaultSaveFileManager(ConfMan.get("savepath"));
|
|
||||||
// TODO remove the debug message eventually
|
// TODO remove the debug message eventually
|
||||||
LOGD("Setting DefaultSaveFileManager path to: %s", ConfMan.get("savepath").c_str());
|
LOGD("Setting DefaultSaveFileManager path to: %s", ConfMan.get("savepath").c_str());
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue