aboutsummaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorMax Horn2007-09-18 20:02:04 +0000
committerMax Horn2007-09-18 20:02:04 +0000
commitc3d3aebe87d16d4fc3b7ac8581b99fb97241c9ac (patch)
tree17b2ba9f45743d2cf8f8e5faa6c9511e213f15f3 /base
parent5c08cb1bcf84828cc93114fadbc89dd6f9909d06 (diff)
parent1dc13a641dd82825334e81bb3eb3b4ebd69d2552 (diff)
downloadscummvm-rg350-c3d3aebe87d16d4fc3b7ac8581b99fb97241c9ac.tar.gz
scummvm-rg350-c3d3aebe87d16d4fc3b7ac8581b99fb97241c9ac.tar.bz2
scummvm-rg350-c3d3aebe87d16d4fc3b7ac8581b99fb97241c9ac.zip
Patch #1768757: Merge fsnode-gsoc into trunk (MAJOR change, will break compilation on some ports)
svn-id: r28944
Diffstat (limited to 'base')
-rw-r--r--base/commandLine.cpp48
1 files changed, 35 insertions, 13 deletions
diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index 985ef8b3cb..20249e758b 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -32,6 +32,7 @@
#include "common/config-manager.h"
#include "common/system.h"
+#include "common/fs.h"
#include "sound/mididrv.h"
#include "sound/mixer.h"
@@ -48,10 +49,6 @@
#define DETECTOR_TESTING_HACK
-#ifdef DETECTOR_TESTING_HACK
-#include "common/fs.h"
-#endif
-
namespace Base {
static const char USAGE_STRING[] =
@@ -313,7 +310,7 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, char **ar
for (int i = 1; i < argc; ++i) {
s = argv[i];
s2 = (i < argc-1) ? argv[i+1] : 0;
-
+
if (s[0] != '-') {
// The argument doesn't start with a dash, so it's not an option.
// Hence it must be the target name. We currently enforce that
@@ -390,7 +387,12 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, char **ar
END_OPTION
DO_OPTION('p', "path")
- // TODO: Verify whether the path is valid
+ FilesystemNode path(option);
+ if(!path.exists()) {
+ usage("Non-existent game path '%s'", option);
+ } else if(!path.isReadable()) {
+ usage("Non-readable game path '%s'", option);
+ }
END_OPTION
DO_OPTION('q', "language")
@@ -428,7 +430,12 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, char **ar
END_OPTION
DO_LONG_OPTION("soundfont")
- // TODO: Verify whether the path is valid
+ FilesystemNode path(option);
+ if(!path.exists()) {
+ usage("Non-existent soundfont path '%s'", option);
+ } else if(!path.isReadable()) {
+ usage("Non-readable soundfont path '%s'", option);
+ }
END_OPTION
DO_LONG_OPTION_BOOL("disable-sdl-parachute")
@@ -453,7 +460,12 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, char **ar
END_OPTION
DO_LONG_OPTION("savepath")
- // TODO: Verify whether the path is valid
+ FilesystemNode path(option);
+ if(!path.exists()) {
+ usage("Non-existent savegames path '%s'", option);
+ } else if(!path.isWritable()) {
+ usage("Non-writable savegames path '%s'", option);
+ }
END_OPTION
DO_LONG_OPTION_INT("talkspeed")
@@ -466,7 +478,12 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, char **ar
END_OPTION
DO_LONG_OPTION("themepath")
- // TODO: Verify whether the path is valid
+ FilesystemNode path(option);
+ if(!path.exists()) {
+ usage("Non-existent theme path '%s'", option);
+ } else if(!path.isReadable()) {
+ usage("Non-readable theme path '%s'", option);
+ }
END_OPTION
DO_LONG_OPTION("target-md5")
@@ -562,7 +579,7 @@ static void runDetectorTest() {
FilesystemNode dir(path);
FSList files;
- if (!dir.listDir(files, FilesystemNode::kListAll)) {
+ if (!dir.getChildren(files, FilesystemNode::kListAll)) {
printf(" ... invalid path, skipping\n");
continue;
}
@@ -673,13 +690,18 @@ bool processSettings(Common::String &command, Common::StringMap &settings) {
if (!settings.contains("savepath")) {
const char *dir = getenv("SCUMMVM_SAVEPATH");
if (dir && *dir && strlen(dir) < MAXPATHLEN) {
- // TODO: Verify whether the path is valid
- settings["savepath"] = dir;
+ FilesystemNode saveDir(dir);
+ if(!saveDir.exists()) {
+ warning("Non-existent SCUMMVM_SAVEPATH save path. It will be ignored.");
+ } else if(!saveDir.isWritable()) {
+ warning("Non-writable SCUMMVM_SAVEPATH save path. It will be ignored.");
+ } else {
+ settings["savepath"] = dir;
+ }
}
}
#endif
-
// Finally, store the command line settings into the config manager.
for (Common::StringMap::const_iterator x = settings.begin(); x != settings.end(); ++x) {
Common::String key(x->_key);