aboutsummaryrefslogtreecommitdiff
path: root/backends/saves/default
diff options
context:
space:
mode:
authorDavid Corrales2007-07-08 07:19:50 +0000
committerDavid Corrales2007-07-08 07:19:50 +0000
commit256e4d9521b79160d1f9ed670656097a96dc5a34 (patch)
tree3ddc7281e7cb01720396d21d0df871766ce5dc4d /backends/saves/default
parent7091babe4ddb1b84a44b4fd53b17649e47d4181b (diff)
downloadscummvm-rg350-256e4d9521b79160d1f9ed670656097a96dc5a34.tar.gz
scummvm-rg350-256e4d9521b79160d1f9ed670656097a96dc5a34.tar.bz2
scummvm-rg350-256e4d9521b79160d1f9ed670656097a96dc5a34.zip
Initial patch to the listSavefiles method. Now only the existing savegames are marked as available.
svn-id: r27957
Diffstat (limited to 'backends/saves/default')
-rw-r--r--backends/saves/default/default-saves.cpp25
-rw-r--r--backends/saves/default/default-saves.h2
2 files changed, 21 insertions, 6 deletions
diff --git a/backends/saves/default/default-saves.cpp b/backends/saves/default/default-saves.cpp
index 1898a23f2a..8c9b0ffd2a 100644
--- a/backends/saves/default/default-saves.cpp
+++ b/backends/saves/default/default-saves.cpp
@@ -28,6 +28,7 @@
#include "common/stdafx.h"
#include "common/savefile.h"
#include "common/util.h"
+#include "common/fs.h"
#include "backends/saves/default/default-saves.h"
#include "backends/saves/compressed/compressed-saves.h"
@@ -179,11 +180,25 @@ Common::InSaveFile *DefaultSaveFileManager::openForLoading(const char *filename)
return wrapInSaveFile(sf);
}
-void DefaultSaveFileManager::listSavefiles(const char * /* prefix */, bool *marks, int num) {
- // TODO: Implement this properly, at least on systems that support
- // opendir/readdir.
- // Even better, replace this with a better design...
- memset(marks, true, num * sizeof(bool));
+void DefaultSaveFileManager::listSavefiles(const char *prefix , bool *marks, int num) {
+ FilesystemNode savePath(getSavePath());
+ FSList savefiles;
+ Common::String search(prefix);
+ search += '*'; //match all files that start with the given prefix
+ search.c_str(); //FIXME: subtle bug? removing this line will break things. Looks like the string isn't getting updated.
+
+ memset(marks, false, num * sizeof(bool)); //assume no savegames for this title
+
+ if(savePath.lookupFile(savefiles, savePath, search, false, true)) {
+ char slot[2];
+ 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];
+ marks[atoi(slot)] = true; //mark this slot as valid
+ }
+ }
}
#endif // !defined(DISABLE_DEFAULT_SAVEFILEMANAGER)
diff --git a/backends/saves/default/default-saves.h b/backends/saves/default/default-saves.h
index 3aea1495a4..a3e2037a5c 100644
--- a/backends/saves/default/default-saves.h
+++ b/backends/saves/default/default-saves.h
@@ -33,7 +33,7 @@ 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 void listSavefiles(const char *prefix, bool *marks, int num);
};
#endif