aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/tizen
diff options
context:
space:
mode:
authorJohannes Schickel2016-02-25 18:33:33 +0100
committerJohannes Schickel2016-02-25 22:15:45 +0100
commitd6d63a16e2c34d3697a26aff97aadf76f1ab4c68 (patch)
tree00067c1f23bc6448722677ca95584f5e052321a6 /backends/platform/tizen
parent8c5931bca4b85c8779bf69aeb04bad5ed4191b79 (diff)
downloadscummvm-rg350-d6d63a16e2c34d3697a26aff97aadf76f1ab4c68.tar.gz
scummvm-rg350-d6d63a16e2c34d3697a26aff97aadf76f1ab4c68.tar.bz2
scummvm-rg350-d6d63a16e2c34d3697a26aff97aadf76f1ab4c68.zip
BACKENDS: Make DefaultSaveFileManager case insensitive.
For this we introduce a file cache inside DefaultSaveFileManager similar to what we use inside FSDirectory. However, we only do small updates for newly created saves (via openForSaving) or for removed saves (via removeSavefile). Re-caching is done whenever the savepath changes. Tizen changes have not been tested.
Diffstat (limited to 'backends/platform/tizen')
-rw-r--r--backends/platform/tizen/system.cpp49
1 files changed, 27 insertions, 22 deletions
diff --git a/backends/platform/tizen/system.cpp b/backends/platform/tizen/system.cpp
index a235456670..1820a28791 100644
--- a/backends/platform/tizen/system.cpp
+++ b/backends/platform/tizen/system.cpp
@@ -81,36 +81,41 @@ struct TizenSaveFileManager : public DefaultSaveFileManager {
};
bool TizenSaveFileManager::removeSavefile(const Common::String &filename) {
- Common::String savePathName = getSavePath();
+ // Assure the savefile name cache is up-to-date.
+ assureCached(getSavePath());
+ if (getError().getCode() != Common::kNoError)
+ return false;
- checkPath(Common::FSNode(savePathName));
- if (getError().getCode() != Common::kNoError) {
+ // Obtain node if exists.
+ SaveFileCache::const_iterator file = _saveFileCache.find(filename);
+ if (file == _saveFileCache.end()) {
return false;
- }
+ } else {
+ const Common::FSNode fileNode = file->_value;
+ // Remove from cache, this invalidates the 'file' iterator.
+ _saveFileCache.erase(file);
+ file = _saveFileCache.end();
- // recreate FSNode since checkPath may have changed/created the directory
- Common::FSNode savePath(savePathName);
- Common::FSNode file = savePath.getChild(filename);
+ String unicodeFileName;
+ StringUtil::Utf8ToString(fileNode.getPath().c_str(), unicodeFileName);
- String unicodeFileName;
- StringUtil::Utf8ToString(file.getPath().c_str(), unicodeFileName);
+ switch (Tizen::Io::File::Remove(unicodeFileName)) {
+ case E_SUCCESS:
+ return true;
- switch (Tizen::Io::File::Remove(unicodeFileName)) {
- case E_SUCCESS:
- return true;
+ case E_ILLEGAL_ACCESS:
+ setError(Common::kWritePermissionDenied, "Search or write permission denied: " +
+ file.getName());
+ break;
- case E_ILLEGAL_ACCESS:
- setError(Common::kWritePermissionDenied, "Search or write permission denied: " +
- file.getName());
- break;
+ default:
+ setError(Common::kPathDoesNotExist, "removeSavefile: '" + file.getName() +
+ "' does not exist or path is invalid");
+ break;
+ }
- default:
- setError(Common::kPathDoesNotExist, "removeSavefile: '" + file.getName() +
- "' does not exist or path is invalid");
- break;
+ return false;
}
-
- return false;
}
//