[Scummvm-cvs-logs] SF.net SVN: scummvm:[33593] residual/trunk/engine
aquadran at users.sourceforge.net
aquadran at users.sourceforge.net
Sun Aug 3 21:39:30 CEST 2008
Revision: 33593
http://scummvm.svn.sourceforge.net/scummvm/?rev=33593&view=rev
Author: aquadran
Date: 2008-08-03 19:39:29 +0000 (Sun, 03 Aug 2008)
Log Message:
-----------
added missing directory creating support for lua io. and support also for windows in default saves code
Modified Paths:
--------------
residual/trunk/engine/backend/saves/default/default-saves.cpp
residual/trunk/engine/lua/liolib.cpp
Modified: residual/trunk/engine/backend/saves/default/default-saves.cpp
===================================================================
--- residual/trunk/engine/backend/saves/default/default-saves.cpp 2008-08-03 19:02:49 UTC (rev 33592)
+++ residual/trunk/engine/backend/saves/default/default-saves.cpp 2008-08-03 19:39:29 UTC (rev 33593)
@@ -42,6 +42,9 @@
#include <sys/stat.h>
#endif
+#ifdef _WIN32
+#include <direct.h>
+#endif
class StdioSaveFile : public Common::InSaveFile, public Common::OutSaveFile {
private:
@@ -196,6 +199,12 @@
setError(SFM_DIR_NOTDIR, "The given savepath is not a directory: "+path);
}
}
+#elif defined(_WIN32)
+ FilesystemNode node(path);
+ if (node.exists() && node.isDirectory())
+ return;
+ if (_mkdir(path.c_str()) == 0)
+ return;
#endif
}
Modified: residual/trunk/engine/lua/liolib.cpp
===================================================================
--- residual/trunk/engine/lua/liolib.cpp 2008-08-03 19:02:49 UTC (rev 33592)
+++ residual/trunk/engine/lua/liolib.cpp 2008-08-03 19:39:29 UTC (rev 33593)
@@ -6,6 +6,7 @@
#include "common/savefile.h"
+#include "common/fs.h"
#include "engine/lua/lauxlib.h"
#include "engine/lua/lua.h"
@@ -17,6 +18,10 @@
#include "engine/savegame.h"
#include "engine/backend/platform/driver.h"
+#ifdef _WIN32
+#include <direct.h>
+#endif
+
#define CLOSEDTAG 2
#define IOTAG 1
@@ -34,6 +39,20 @@
extern Common::SaveFileManager *g_saveFileMan;
+static void checkPath(const Common::String &path) {
+ FilesystemNode node(path);
+ if (node.exists() && node.isDirectory())
+ return;
+#if defined(UNIX) || defined(__SYMBIAN32__)
+ if (mkdir(path.c_str(), 0755) == 0)
+ return;
+#elif defined(_WIN32)
+ if (_mkdir(path.c_str()) == 0)
+ return;
+#endif
+ warning("Can't creating missing director for save path: %s", path.c_str());
+}
+
static void join_paths(const char *filename, const char *directory,
char *buf, int bufsize) {
buf[bufsize - 1] = '\0';
@@ -137,6 +156,7 @@
if (dir.empty())
dir = ConfMan.get("path");
#endif
+ checkPath(dir);
char buf[256];
join_paths(s, dir.c_str(), buf, sizeof(buf));
if (current->exists(buf))
@@ -173,6 +193,7 @@
if (dir.empty())
dir = ConfMan.get("path");
#endif
+ checkPath(dir);
char buf[256];
join_paths(s, dir.c_str(), buf, sizeof(buf));
current->open(buf, Common::File::kFileWriteMode);
@@ -193,6 +214,7 @@
if (dir.empty())
dir = ConfMan.get("path");
#endif
+ checkPath(dir);
char path[256];
join_paths(s, dir.c_str(), path, sizeof(path));
file.open(path);
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