diff options
author | David Corrales | 2007-07-12 17:58:15 +0000 |
---|---|---|
committer | David Corrales | 2007-07-12 17:58:15 +0000 |
commit | 720c974fafaca16b6e86f28ffc14c8c3aa574e15 (patch) | |
tree | d2d1ad9231fdc85099e12234ea14e5e50a89d8be /backends | |
parent | c1961f1f76e91595624a2e49e48b0fab5f412f27 (diff) | |
download | scummvm-rg350-720c974fafaca16b6e86f28ffc14c8c3aa574e15.tar.gz scummvm-rg350-720c974fafaca16b6e86f28ffc14c8c3aa574e15.tar.bz2 scummvm-rg350-720c974fafaca16b6e86f28ffc14c8c3aa574e15.zip |
Changed SaveFileManager::listSavegames() function to be engine agnostic. It now returns a list will the full paths of existing files that match a given regex.
Additionally, modified the 5 engines which use the default manager (Agos, Queen, Saga, Scumm and Touche) to parse the filename list and mark the available saves bool array correctly.
svn-id: r28046
Diffstat (limited to 'backends')
-rw-r--r-- | backends/saves/default/default-saves.cpp | 22 | ||||
-rw-r--r-- | backends/saves/default/default-saves.h | 3 |
2 files changed, 8 insertions, 17 deletions
diff --git a/backends/saves/default/default-saves.cpp b/backends/saves/default/default-saves.cpp index 8cda56ded9..2219d1c9dc 100644 --- a/backends/saves/default/default-saves.cpp +++ b/backends/saves/default/default-saves.cpp @@ -180,29 +180,19 @@ Common::InSaveFile *DefaultSaveFileManager::openForLoading(const char *filename) return wrapInSaveFile(sf); } -void DefaultSaveFileManager::listSavefiles(const char *prefix , bool *marks, int num) { +Common::StringList DefaultSaveFileManager::listSavefiles(const char *regex) { FilesystemNode savePath(getSavePath()); FSList savefiles; - Common::String search(prefix); - search = search + '*'; //match all files that start with the given prefix. += causes a strange bug. + Common::StringList results; + Common::String search(regex); - assert(marks); - memset(marks, false, num * sizeof(bool)); //assume no savegames for this title - if(savePath.lookupFile(savefiles, savePath, search, false, true)) { - char slot[2]; - int slotNum; for(FSList::const_iterator file = savefiles.begin(); file != savefiles.end(); file++) { - //TODO: check if this is the behavior for all engines - //Obtain the last 2 digits of the filename, since they correspond to the save slot - slot[0] = file->getName()[file->getName().size()-2]; - slot[1] = file->getName()[file->getName().size()-1]; - - slotNum = atoi(slot); - if(slotNum >= 0 && slotNum < num) - marks[slotNum] = true; //mark this slot as valid + results.push_back(file->getPath()); } } + + return results; } #endif // !defined(DISABLE_DEFAULT_SAVEFILEMANAGER) diff --git a/backends/saves/default/default-saves.h b/backends/saves/default/default-saves.h index a3e2037a5c..4b525cabc8 100644 --- a/backends/saves/default/default-saves.h +++ b/backends/saves/default/default-saves.h @@ -28,12 +28,13 @@ #include "common/stdafx.h" #include "common/savefile.h" +#include "common/str.h" class DefaultSaveFileManager : public Common::SaveFileManager { public: virtual Common::OutSaveFile *openForSaving(const char *filename); virtual Common::InSaveFile *openForLoading(const char *filename); - virtual void listSavefiles(const char *prefix, bool *marks, int num); + virtual Common::StringList listSavefiles(const char *regex); }; #endif |