X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=fs.c;h=58c5ed0a0ab763c3aca028185f94c3306c7b5e30;hb=3eaf4d428c06dcf2f08beccb8a613de02a5498aa;hp=46172798fe28f0a4f91ab0a677d99e14ad654cc1;hpb=f7e37f88d839aaf88b304e2cfc000bf10ca9ed83;p=xonotic%2Fdarkplaces.git diff --git a/fs.c b/fs.c index 46172798..58c5ed0a 100644 --- a/fs.c +++ b/fs.c @@ -273,7 +273,7 @@ char fs_basedir[MAX_OSPATH]; qboolean fs_modified; // set true if using non-id files -cvar_t scr_screenshot_name = {0, "scr_screenshot_name","dp"}; +cvar_t scr_screenshot_name = {0, "scr_screenshot_name","dp", "prefix name for saved screenshots (changes based on -game commandline, as well as which game mode is running)"}; /* @@ -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 [] ... // Fully specifies the exact search path, overriding the generated one // COMMANDLINEOPTION: Filesystem: -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) @@ -1054,9 +1058,9 @@ void FS_Init_Commands(void) { Cvar_RegisterVariable (&scr_screenshot_name); - Cmd_AddCommand ("path", FS_Path_f); - Cmd_AddCommand ("dir", FS_Dir_f); - Cmd_AddCommand ("ls", FS_Ls_f); + Cmd_AddCommand ("path", FS_Path_f, "print searchpath (game directories and archives)"); + Cmd_AddCommand ("dir", FS_Dir_f, "list files in searchpath matching an * filename pattern, one per line"); + Cmd_AddCommand ("ls", FS_Ls_f, "list files in searchpath matching an * filename pattern, multiple per line"); // set the default screenshot name to either the mod name or the // gamemode screenshot name @@ -1327,8 +1331,8 @@ static searchpath_t *FS_FindFile (const char *name, int* index, qboolean quiet) // Found it if (!diff) { - if (!quiet) - Con_DPrintf("FS_FindFile: %s in %s\n", + if (!quiet && developer.integer >= 10) + Con_Printf("FS_FindFile: %s in %s\n", pak->files[middle].name, pak->filename); if (index != NULL) @@ -1349,8 +1353,8 @@ static searchpath_t *FS_FindFile (const char *name, int* index, qboolean quiet) dpsnprintf(netpath, sizeof(netpath), "%s%s", search->filename, name); if (FS_SysFileExists (netpath)) { - if (!quiet) - Con_DPrintf("FS_FindFile: %s\n", netpath); + if (!quiet && developer.integer >= 10) + Con_Printf("FS_FindFile: %s\n", netpath); if (index != NULL) *index = -1; @@ -1359,8 +1363,8 @@ static searchpath_t *FS_FindFile (const char *name, int* index, qboolean quiet) } } - if (!quiet) - Con_DPrintf("FS_FindFile: can't find %s\n", name); + if (!quiet && developer.integer >= 10) + Con_Printf("FS_FindFile: can't find %s\n", name); if (index != NULL) *index = -1; @@ -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); @@ -1712,18 +1716,17 @@ Print a string into a file int FS_VPrintf (qfile_t* file, const char* format, va_list ap) { int len; - fs_offset_t buff_size; - char *tempbuff = NULL; + fs_offset_t buff_size = MAX_INPUTLINE; + char *tempbuff; - buff_size = 1024; - tempbuff = (char *)Mem_Alloc (tempmempool, buff_size); - len = dpvsnprintf (tempbuff, buff_size, format, ap); - while (len < 0) + for (;;) { - Mem_Free (tempbuff); - buff_size *= 2; tempbuff = (char *)Mem_Alloc (tempmempool, buff_size); len = dpvsnprintf (tempbuff, buff_size, format, ap); + if (len >= 0 && len < buff_size) + break; + Mem_Free (tempbuff); + buff_size *= 2; } len = write (file->handle, tempbuff, len); @@ -2219,7 +2222,7 @@ int FS_ListDirectory(const char *pattern, int oneperline) int linebufpos; int i, j, k, l; const char *name; - char linebuf[4096]; + char linebuf[MAX_INPUTLINE]; fssearch_t *search; search = FS_Search(pattern, true, true); if (!search)