[Scummvm-git-logs] scummvm master -> c28d246cb0d8ad7773eef8008fd18dae53abbdbf

yinsimei roseline.yin at gmail.com
Fri Aug 11 18:04:32 CEST 2017


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
c28d246cb0 SLUDGE: Get list of saved files


Commit: c28d246cb0d8ad7773eef8008fd18dae53abbdbf
    https://github.com/scummvm/scummvm/commit/c28d246cb0d8ad7773eef8008fd18dae53abbdbf
Author: Simei Yin (roseline.yin at gmail.com)
Date: 2017-08-11T18:03:45+02:00

Commit Message:
SLUDGE: Get list of saved files

Changed paths:
    engines/sludge/variable.cpp


diff --git a/engines/sludge/variable.cpp b/engines/sludge/variable.cpp
index 4579dc8..fb4f191 100644
--- a/engines/sludge/variable.cpp
+++ b/engines/sludge/variable.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "common/debug.h"
+#include "common/savefile.h"
 
 #include "sludge/allfiles.h"
 #include "sludge/variable.h"
@@ -141,35 +142,28 @@ int stackSize(const StackHandler *me) {
 }
 
 bool getSavedGamesStack(StackHandler *sH, const Common::String &ext) {
-#if 0
+
+	// Make pattern
+	uint len = ext.size();
 	Common::String pattern = "*";
 	pattern += ext;
 
+	// Get all saved files
+	Common::StringArray sa = g_system->getSavefileManager()->listSavefiles(pattern);
+
+	// Save file names to stacks
 	Variable newName;
 	newName.varType = SVT_NULL;
-
-	DIR *dir = opendir(".");
-	if (!dir)
-		return false;
-
-	struct dirent *d = readdir(dir);
-	while (d != NULL) {
-		if (!strcmp(d->d_name + strlen(d->d_name) - strlen(ext), ext)) {
-			d->d_name[strlen(d->d_name) - strlen(ext)] = 0;
-			char *decoded = decodeFilename(d->d_name);
-			makeTextVar(newName, decoded);
-			delete[] decoded;
-			if (!addVarToStack(newName, sH->first))
-				return false;
-			if (sH->last == NULL)
-				sH->last = sH->first;
-		}
-
-		d = readdir(dir);
+	Common::StringArray::iterator it;
+	for (it = sa.begin(); it != sa.end(); ++it) {
+		(*it).erase((*it).size() - len, len);
+		makeTextVar(newName, (*it));
+		if (!addVarToStack(newName, sH->first))
+			return false;
+		if (sH->last == NULL)
+			sH->last = sH->first;
 	}
 
-	closedir(dir);
-#endif
 	return true;
 }
 





More information about the Scummvm-git-logs mailing list