diff options
| author | Stijn Buys <ingar@osirion.org> | 2008-09-18 17:35:58 +0000 | 
|---|---|---|
| committer | Stijn Buys <ingar@osirion.org> | 2008-09-18 17:35:58 +0000 | 
| commit | 84a53f91e64ad801703bcf2c73a82b75ff10d760 (patch) | |
| tree | bc187f6586d9527e3d6cd6d01b36036bd12f9695 /src/filesystem | |
| parent | b6fcc157dad58d4fab32e01ea161acf20ab434a1 (diff) | |
fix win32 build and directory creation, use My Games\
Diffstat (limited to 'src/filesystem')
| -rw-r--r-- | src/filesystem/filesystem.cc | 29 | 
1 files changed, 26 insertions, 3 deletions
diff --git a/src/filesystem/filesystem.cc b/src/filesystem/filesystem.cc index 0fec129..3404296 100644 --- a/src/filesystem/filesystem.cc +++ b/src/filesystem/filesystem.cc @@ -8,6 +8,13 @@  #include <list> +#ifdef _WIN32 + +#include <windows.h> +#include <shlobj.h> + +#endif +  #include "filesystem/filesystem.h"  #include "filesystem/diskfile.h"  #include "filesystem/file.h" @@ -54,8 +61,25 @@ void init(std::string const & basename, std::string const & modname)  	filesystem_homedir.assign(getenv("HOME"));  	filesystem_homedir.append("/.osirion/");  #else -	// FIXME win32 -	filesystem_homedir.assign("home/"); +	char mydocuments[512]; +	memset(mydocuments, 0, sizeof(mydocuments)); + +	SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, mydocuments); +	filesystem_homedir.assign(mydocuments); + +	if (filesystem_homedir.size()) { +		filesystem_homedir.append("\\My Games"); +		if (!sys::isdirectory(filesystem_homedir)) +			sys::mkdir(filesystem_homedir); + +		filesystem_homedir.append("\\Osirion"); +		if (!sys::isdirectory(filesystem_homedir)) +			sys::mkdir(filesystem_homedir); + +		filesystem_homedir.append("\\"); +	} else { +		filesystem_homedir.assign("home/"); +	}  #endif  	std::string current_datadir("data/"); @@ -77,7 +101,6 @@ void init(std::string const & basename, std::string const & modname)  	sys::mkdir(filesystem_homedir);  	sys::mkdir(filesystem_writedir); -  	// modname search path  	if (filesystem_modname.size()) {  		// HOME/modname  | 
