return true;
// Load the DLL
- if (! Sys_LoadLibrary (dllnames, &zlib_dll, zlibfuncs))
- {
- Con_Printf ("Compressed files support disabled\n");
- return false;
- }
-
- Con_Printf ("Compressed files support enabled\n");
- return true;
+ return Sys_LoadLibrary (dllnames, &zlib_dll, zlibfuncs);
}
int i;
stringlist_t list;
searchpath_t *search;
- char pakfile[MAX_OSPATH];
strlcpy (fs_gamedir, dir, sizeof (fs_gamedir));
stringlistinit(&list);
- listdirectory(&list, dir);
+ listdirectory(&list, "", dir);
stringlistsort(&list);
// add any PAK package in the directory
{
if (!strcasecmp(FS_FileExtension(list.strings[i]), "pak"))
{
- dpsnprintf (pakfile, sizeof (pakfile), "%s%s", dir, list.strings[i]);
- FS_AddPack_Fullpath(pakfile, NULL, false);
+ FS_AddPack_Fullpath(list.strings[i], NULL, false);
}
}
{
if (!strcasecmp(FS_FileExtension(list.strings[i]), "pk3"))
{
- dpsnprintf (pakfile, sizeof (pakfile), "%s%s", dir, list.strings[i]);
- FS_AddPack_Fullpath(pakfile, NULL, false);
+ FS_AddPack_Fullpath(list.strings[i], NULL, false);
}
}
#ifdef WIN32
if(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, mydocsdir) == S_OK)
dpsnprintf(userdir, sizeof(userdir), "%s/My Games/%s/", mydocsdir, gameuserdirname);
- fprintf(stderr, "userdir = %s\n", userdir);
#else
homedir = getenv ("HOME");
if(homedir)
if(COM_CheckParm("-nohome"))
*userdir = 0;
-
+
if((i = COM_CheckParm("-userdir")) && i < com_argc - 1)
dpsnprintf(userdir, sizeof(userdir), "%s/", com_argv[i+1]);
}
}
- // halt demo playback to close the file
- CL_Disconnect();
-
Host_SaveConfig();
fs_numgamedirs = numgamedirs;
return;
}
+ // halt demo playback to close the file
+ CL_Disconnect();
+
FS_ChangeGameDirs(numgamedirs, gamedirs, true, true);
}
qboolean success;
stringlist_t list;
stringlistinit(&list);
- listdirectory(&list, va("%s%s/", fs_basedir, gamedir));
+ listdirectory(&list, va("%s%s/", fs_basedir, gamedir), "");
success = list.numstrings > 0;
stringlistfreecontents(&list);
return success;
strlcat(fs_basedir, "/", sizeof(fs_basedir));
if (!FS_CheckGameDir(gamedirname1))
- Sys_Error("base gamedir %s%s/ not found!\n", fs_basedir, gamedirname1);
+ Con_Printf("WARNING: base gamedir %s%s/ not found!\n", fs_basedir, gamedirname1);
if (gamedirname2 && !FS_CheckGameDir(gamedirname2))
- Sys_Error("base gamedir %s%s/ not found!\n", fs_basedir, gamedirname2);
+ Con_Printf("WARNING: base gamedir %s%s/ not found!\n", fs_basedir, gamedirname2);
// -game <gamedir>
// Adds basedir/gamedir as an override game
if (FS_CheckNastyPath(com_argv[i], true))
Sys_Error("-game %s%s/ is a dangerous/non-portable path\n", fs_basedir, com_argv[i]);
if (!FS_CheckGameDir(com_argv[i]))
- Sys_Error("-game %s%s/ not found!\n", fs_basedir, com_argv[i]);
+ Con_Printf("WARNING: -game %s%s/ not found!\n", fs_basedir, com_argv[i]);
// add the gamedir to the list of active gamedirs
strlcpy (fs_gamedirs[fs_numgamedirs], com_argv[i], sizeof(fs_gamedirs[fs_numgamedirs]));
fs_numgamedirs++;
{
#ifdef FS_FIX_PATHS
char fixedFileName[MAX_QPATH];
- char *d = fixedFileName;
+ char *d;
+ strlcpy( fixedFileName, filepath, MAX_QPATH );
// try to fix common mistakes (\ instead of /)
- for( ; *filepath ; filepath++, d++ )
- if( *filepath != '\\' )
- *d = *filepath;
- else
+ for( d = fixedFileName ; *d ; d++ )
+ if( *d == '\\' )
*d = '/';
- *d = '\0';
filepath = fixedFileName;
#endif
buf[filesize] = '\0';
FS_Read (file, buf, filesize);
FS_Close (file);
+ if (developer_loadfile.integer)
+ Con_Printf("loaded file \"%s\" (%u bytes)\n", path, (unsigned int)filesize);
}
if (filesizepointer)
return false;
}
- Con_DPrintf("FS_WriteFile: %s\n", filename);
+ Con_DPrintf("FS_WriteFile: %s (%u bytes)\n", filename, (unsigned int)len);
FS_Write (file, data, len);
FS_Close (file);
return true;
stringlist_t dirlist;
const char *slash, *backslash, *colon, *separator;
char *basepath;
- char netpath[MAX_OSPATH];
char temp[MAX_OSPATH];
for (i = 0;pattern[i] == '.' || pattern[i] == ':' || pattern[i] == '/' || pattern[i] == '\\';i++)
if (resultlistindex == resultlist.numstrings)
{
stringlistappend(&resultlist, temp);
- if (!quiet)
- Con_DPrintf("SearchPackFile: %s : %s\n", pak->filename, temp);
+ if (!quiet && developer_loading.integer)
+ Con_Printf("SearchPackFile: %s : %s\n", pak->filename, temp);
}
}
// strip off one path element at a time until empty
}
else
{
- // get a directory listing and look at each name
- dpsnprintf(netpath, sizeof (netpath), "%s%s", searchpath->filename, basepath);
- stringlistinit(&dirlist);
- listdirectory(&dirlist, netpath);
- for (dirlistindex = 0;dirlistindex < dirlist.numstrings;dirlistindex++)
+ stringlist_t matchedSet, foundSet;
+ const char *start = pattern;
+
+ stringlistinit(&matchedSet);
+ stringlistinit(&foundSet);
+ // add a first entry to the set
+ stringlistappend(&matchedSet, "");
+ // iterate through pattern's path
+ while (*start)
+ {
+ const char *asterisk, *wildcard, *nextseparator, *prevseparator;
+ char subpath[MAX_OSPATH];
+ char subpattern[MAX_OSPATH];
+
+ // find the next wildcard
+ wildcard = strchr(start, '?');
+ asterisk = strchr(start, '*');
+ if (asterisk && (!wildcard || asterisk < wildcard))
+ {
+ wildcard = asterisk;
+ }
+
+ if (wildcard)
+ {
+ nextseparator = strchr( wildcard, '/' );
+ }
+ else
+ {
+ nextseparator = NULL;
+ }
+
+ if( !nextseparator ) {
+ nextseparator = start + strlen( start );
+ }
+
+ // prevseparator points past the '/' right before the wildcard and nextseparator at the one following it (or at the end of the string)
+ // copy everything up except nextseperator
+ strlcpy(subpattern, pattern, min(sizeof(subpattern), (size_t) (nextseparator - pattern + 1)));
+ // find the last '/' before the wildcard
+ prevseparator = strrchr( subpattern, '/' ) + 1;
+ if (!prevseparator)
+ {
+ prevseparator = subpattern;
+ }
+ // copy everything from start to the previous including the '/' (before the wildcard)
+ // everything up to start is already included in the path of matchedSet's entries
+ strlcpy(subpath, start, min(sizeof(subpath), (size_t) ((prevseparator - subpattern) - (start - pattern) + 1)));
+
+ // for each entry in matchedSet try to open the subdirectories specified in subpath
+ for( dirlistindex = 0 ; dirlistindex < matchedSet.numstrings ; dirlistindex++ ) {
+ strlcpy( temp, matchedSet.strings[ dirlistindex ], sizeof(temp) );
+ strlcat( temp, subpath, sizeof(temp) );
+ listdirectory( &foundSet, searchpath->filename, temp );
+ }
+ if( dirlistindex == 0 ) {
+ break;
+ }
+ // reset the current result set
+ stringlistfreecontents( &matchedSet );
+ // match against the pattern
+ for( dirlistindex = 0 ; dirlistindex < foundSet.numstrings ; dirlistindex++ ) {
+ const char *direntry = foundSet.strings[ dirlistindex ];
+ if (matchpattern(direntry, subpattern, true)) {
+ stringlistappend( &matchedSet, direntry );
+ }
+ }
+ stringlistfreecontents( &foundSet );
+
+ start = nextseparator;
+ }
+
+ for (dirlistindex = 0;dirlistindex < matchedSet.numstrings;dirlistindex++)
{
- dpsnprintf(temp, sizeof(temp), "%s%s", basepath, dirlist.strings[dirlistindex]);
+ const char *temp = matchedSet.strings[dirlistindex];
if (matchpattern(temp, (char *)pattern, true))
{
for (resultlistindex = 0;resultlistindex < resultlist.numstrings;resultlistindex++)
if (resultlistindex == resultlist.numstrings)
{
stringlistappend(&resultlist, temp);
- if (!quiet)
- Con_DPrintf("SearchDirFile: %s\n", temp);
+ if (!quiet && developer_loading.integer)
+ Con_Printf("SearchDirFile: %s\n", temp);
}
}
}
- stringlistfreecontents(&dirlist);
+ stringlistfreecontents( &matchedSet );
}
}