]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
changed basedir and gamedir handling slightly to eliminate the need for "./" paths
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 27 Dec 2005 09:56:31 +0000 (09:56 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 27 Dec 2005 09:56:31 +0000 (09:56 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5870 d7cf8633-e32d-0410-b094-e92efae38249

fs.c

diff --git a/fs.c b/fs.c
index fd20cdc17a9b689c96817c4fa6fe98e278b533fa..0b033104b75ac5cbde2a4b898e5a11a0c4d05fb2 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -894,7 +894,7 @@ void FS_AddGameHierarchy (const char *dir)
 #endif
 
        // Add the common game directory
-       FS_AddGameDirectory (va("%s/%s/", fs_basedir, dir));
+       FS_AddGameDirectory (va("%s%s/", fs_basedir, dir));
 
 #ifndef WIN32
        // Add the personal game directory
@@ -942,7 +942,7 @@ void FS_Init (void)
 
        fs_mempool = Mem_AllocPool("file management", 0, NULL);
 
-       strcpy(fs_basedir, ".");
+       strcpy(fs_basedir, "");
        strcpy(fs_gamedir, "");
 
 #ifdef MACOSX
@@ -973,6 +973,10 @@ void FS_Init (void)
                        fs_basedir[i-1] = 0;
        }
 
+       // add a path separator to the end of the basedir if it lacks one
+       if (fs_basedir[0] && fs_basedir[strlen(fs_basedir) - 1] != '/' && fs_basedir[strlen(fs_basedir) - 1] != '\\')
+               strlcat(fs_basedir, "/", sizeof(fs_basedir));
+
        // -path <dir or packfile> [<dir or packfile>] ...
        // Fully specifies the exact search path, overriding the generated one
 // COMMANDLINEOPTION: Filesystem: -path <path ..> specifies the full search path manually, overriding the generated one, example: -path c:\quake\id1 c:\quake\pak0.pak c:\quake\pak1.pak (not recommended)
@@ -1428,7 +1432,7 @@ qfile_t* FS_Open (const char* filepath, const char* mode, qboolean quiet, qboole
                char real_path [MAX_OSPATH];
 
                // Open the file on disk directly
-               dpsnprintf (real_path, sizeof (real_path), "%s%s", fs_gamedir, filepath);
+               dpsnprintf (real_path, sizeof (real_path), "%s/%s", fs_gamedir, filepath);
 
                // Create directories up to the file
                FS_CreatePath (real_path);