COMMON: Introduce SaveFileManager::exists
Checks if a savefile with given name exists. Implement on all backends.
This commit is contained in:
parent
fb8f233ed7
commit
a0c818bde6
6 changed files with 36 additions and 0 deletions
|
@ -336,6 +336,10 @@ public:
|
|||
}
|
||||
|
||||
Common::StringArray listSavefiles(const Common::String &pattern) override;
|
||||
|
||||
bool exists(const Common::String &filename) override {
|
||||
return InVMSave().readSaveGame(filename.c_str());
|
||||
}
|
||||
};
|
||||
|
||||
void OutVMSave::finalize()
|
||||
|
|
|
@ -143,6 +143,10 @@ public:
|
|||
}
|
||||
|
||||
Common::StringArray listSavefiles(const Common::String &pattern) override;
|
||||
|
||||
bool exists(const Common::String &filename) override {
|
||||
return InFRAMSave().readSaveGame(filename.c_str());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -145,6 +145,10 @@ public:
|
|||
}
|
||||
|
||||
Common::StringArray listSavefiles(const Common::String &pattern) override;
|
||||
|
||||
bool exists(const Common::String &filename) override {
|
||||
return InPAKSave().readSaveGame(filename.c_str());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -222,6 +222,20 @@ bool DefaultSaveFileManager::removeSavefile(const Common::String &filename) {
|
|||
}
|
||||
}
|
||||
|
||||
bool DefaultSaveFileManager::exists(const Common::String &filename) {
|
||||
// Assure the savefile name cache is up-to-date.
|
||||
assureCached(getSavePath());
|
||||
if (getError().getCode() != Common::kNoError)
|
||||
return false;
|
||||
|
||||
for (Common::StringArray::const_iterator i = _lockedFiles.begin(), end = _lockedFiles.end(); i != end; ++i) {
|
||||
if (filename == *i)
|
||||
return true;
|
||||
}
|
||||
|
||||
return _saveFileCache.contains(filename);
|
||||
}
|
||||
|
||||
Common::String DefaultSaveFileManager::getSavePath() const {
|
||||
|
||||
Common::String dir;
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
Common::InSaveFile *openForLoading(const Common::String &filename) override;
|
||||
Common::OutSaveFile *openForSaving(const Common::String &filename, bool compress = true) override;
|
||||
bool removeSavefile(const Common::String &filename) override;
|
||||
bool exists(const Common::String &filename) override;
|
||||
|
||||
#ifdef USE_LIBCURL
|
||||
|
||||
|
|
|
@ -268,6 +268,15 @@ public:
|
|||
* for saving or loading because they are being synced by CloudManager.
|
||||
*/
|
||||
virtual void updateSavefilesList(StringArray &lockedFiles) = 0;
|
||||
|
||||
/**
|
||||
* Checks if the savefile exists.
|
||||
*
|
||||
* @param name Name of the save file.
|
||||
*
|
||||
* @return true if the file exists. false otherwise.
|
||||
*/
|
||||
virtual bool exists(const String &name) = 0;
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue