Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2009-01-12 20:54:21 +0000
committerStijn Buys <ingar@osirion.org>2009-01-12 20:54:21 +0000
commit9c844f666405eaa94df3740c5423ab0e932d4ea8 (patch)
treeba8c5f81aef517af513064a6658695223ec34691 /src/filesystem
parent784e5c24d505aab001ae398cd53b039baed59f1f (diff)
fix directory warnings on win32
Diffstat (limited to 'src/filesystem')
-rw-r--r--src/filesystem/filesystem.cc30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/filesystem/filesystem.cc b/src/filesystem/filesystem.cc
index 19869a9..d275667 100644
--- a/src/filesystem/filesystem.cc
+++ b/src/filesystem/filesystem.cc
@@ -57,10 +57,19 @@ void init(std::string const & basename, std::string const & modname)
filesystem_basename.assign("base");
filesystem_modname.assign(modname);
+
#ifndef _WIN32
+ // UNIX home directory is $HOME/.osirion
filesystem_homedir.assign(getenv("HOME"));
- filesystem_homedir.append("/.osirion/");
+ filesystem_homedir.append("/.osirion");
+
+ // create homedir if necessary
+ if (!sys::isdirectory(filesystem_homedir))
+ sys::mkdir(filesystem_homedir);
+ filesystem_homedir += '/';
+
#else
+ // windows home directory is My Documents\My Games\Osirion
char mydocuments[512];
memset(mydocuments, 0, sizeof(mydocuments));
@@ -75,10 +84,15 @@ void init(std::string const & basename, std::string const & modname)
filesystem_homedir.append("\\Osirion");
if (!sys::isdirectory(filesystem_homedir))
sys::mkdir(filesystem_homedir);
-
filesystem_homedir.append("\\");
+
} else {
- filesystem_homedir.assign("home/");
+ con_warn << "using fallback home directory" << std::endl;
+
+ filesystem_homedir.assign("home");
+ if (!sys::isdirectory(filesystem_homedir))
+ sys::mkdir(filesystem_homedir);
+ filesystem_homedir += '/';
}
#endif
@@ -91,15 +105,15 @@ void init(std::string const & basename, std::string const & modname)
if (filesystem_modname.size()) {
// append modname to writedir
filesystem_writedir.append(filesystem_modname);
- filesystem_writedir += '/';
} else {
// append basename to writedir
- filesystem_writedir.append(filesystem_basename);
- filesystem_writedir += '/';
+ filesystem_writedir.append(filesystem_basename);
}
- sys::mkdir(filesystem_homedir);
- sys::mkdir(filesystem_writedir);
+ // create writedir if necessary
+ if (!sys::isdirectory(filesystem_writedir))
+ sys::mkdir(filesystem_writedir);
+ filesystem_writedir += '/';
// modname search path
if (filesystem_modname.size()) {