[Scummvm-cvs-logs] SF.net SVN: scummvm: [27957] scummvm/branches/gsoc2007-fsnode/backends/ saves/default
david_corrales at users.sourceforge.net
david_corrales at users.sourceforge.net
Sun Jul 8 09:19:51 CEST 2007
Revision: 27957
http://scummvm.svn.sourceforge.net/scummvm/?rev=27957&view=rev
Author: david_corrales
Date: 2007-07-08 00:19:50 -0700 (Sun, 08 Jul 2007)
Log Message:
-----------
Initial patch to the listSavefiles method. Now only the existing savegames are marked as available.
Modified Paths:
--------------
scummvm/branches/gsoc2007-fsnode/backends/saves/default/default-saves.cpp
scummvm/branches/gsoc2007-fsnode/backends/saves/default/default-saves.h
Modified: scummvm/branches/gsoc2007-fsnode/backends/saves/default/default-saves.cpp
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/saves/default/default-saves.cpp 2007-07-08 03:08:29 UTC (rev 27956)
+++ scummvm/branches/gsoc2007-fsnode/backends/saves/default/default-saves.cpp 2007-07-08 07:19:50 UTC (rev 27957)
@@ -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 @@
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)
Modified: scummvm/branches/gsoc2007-fsnode/backends/saves/default/default-saves.h
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/saves/default/default-saves.h 2007-07-08 03:08:29 UTC (rev 27956)
+++ scummvm/branches/gsoc2007-fsnode/backends/saves/default/default-saves.h 2007-07-08 07:19:50 UTC (rev 27957)
@@ -33,7 +33,7 @@
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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list