Q_mkdir(g_qeglobals.m_userEnginePath.c_str());
}
else
+#elif defined(WIN32)
+ if(!string_empty(prefix))
+ {
+ StringOutputStream path(256);
+ TCHAR mydocsdir[MAX_PATH + 1];
+ if(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, mydocsdir))
+ {
+ path << DirectoryCleaned(mydocsdir) << "My Games/" << prefix << "/";
+ // win32: only add it if it already exists
+ if(file_is_directory(path.c_str()))
+ g_qeglobals.m_userEnginePath = path.c_str();
+ else
+ g_qeglobals.m_userEnginePath = EnginePath_get();
+ }
+ else
+ {
+ g_qeglobals.m_userEnginePath = EnginePath_get();
+ }
+ }
+ else
#endif
{
g_qeglobals.m_userEnginePath = EnginePath_get();
const char* gamename = gamename_get();
const char* basegame = basegame_get();
-#if defined(POSIX)
const char* userRoot = g_qeglobals.m_userEnginePath.c_str();
-#endif
const char* globalRoot = EnginePath_get();
// if we have a mod dir
if(!string_equal(gamename, basegame))
{
-#if defined(POSIX)
// ~/.<gameprefix>/<fs_game>
+ if(userRoot)
{
StringOutputStream userGamePath(256);
userGamePath << userRoot << gamename << '/';
GlobalFileSystem().initDirectory(userGamePath.c_str());
}
-#endif
// <fs_basepath>/<fs_game>
{
}
}
-#if defined(POSIX)
// ~/.<gameprefix>/<fs_main>
+ if(userRoot)
{
StringOutputStream userBasePath(256);
userBasePath << userRoot << basegame << '/';
GlobalFileSystem().initDirectory(userBasePath.c_str());
}
-#endif
// <fs_basepath>/<fs_main>
{
char *LokiGetHomeDir( void )
{
#ifndef Q_UNIX
- return NULL;
+ #ifndef WIN32
+ return NULL;
+ #else
+ static char buf[MAX_OS_PATH];
+ TCHAR mydocsdir[MAX_PATH + 1];
+ if(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, mydocsdir))
+ {
+ snprintf(buf, "%s/My Games", mydocsdir);
+ return buf;
+ }
+ return NULL;
+ #endif
#else
char *home;
uid_t id;
#ifndef Q_UNIX
/* this is kinda crap, but hey */
strcpy( installPath, "../" );
+
+ /* get home dir */
+ home = LokiGetHomeDir();
+ if( home == NULL )
+ home = ".";
+
+ /* set home path */
+ homePath = home;
#else
char temp[ MAX_OS_PATH ];
char last0[ 2 ];
void AddHomeBasePath( char *path )
{
- #ifdef Q_UNIX
- int i;
- char temp[ MAX_OS_PATH ];
-
-
- /* dummy check */
- if( path == NULL || path[ 0 ] == '\0' )
+ int i;
+ char temp[ MAX_OS_PATH ];
+
+ if(!homePath)
+ return;
+
+ /* dummy check */
+ if( path == NULL || path[ 0 ] == '\0' )
+ return;
+
+ /* concatenate home dir and path */
+ sprintf( temp, "%s/%s", homePath, path );
+
+#ifdef WIN32
+ {
+ /* on Win32, we ONLY add it if the directory already exists */
+ GDir *dir;
+ dir = g_dir_open (temp, 0, NULL);
+ if(!dir)
return;
+ g_dir_close(dir);
+ }
+#endif
- /* make a hole */
- for( i = (MAX_BASE_PATHS - 2); i >= 0; i-- )
- basePaths[ i + 1 ] = basePaths[ i ];
-
- /* concatenate home dir and path */
- sprintf( temp, "%s/%s", homePath, path );
-
- /* add it to the list */
- basePaths[ 0 ] = safe_malloc( strlen( temp ) + 1 );
- strcpy( basePaths[ 0 ], temp );
- CleanPath( basePaths[ 0 ] );
- numBasePaths++;
- #endif
+ /* make a hole */
+ for( i = (MAX_BASE_PATHS - 2); i >= 0; i-- )
+ basePaths[ i + 1 ] = basePaths[ i ];
+
+ /* add it to the list */
+ basePaths[ 0 ] = safe_malloc( strlen( temp ) + 1 );
+ strcpy( basePaths[ 0 ], temp );
+ CleanPath( basePaths[ 0 ] );
+ numBasePaths++;
}