mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-26 22:40:50 +00:00
Remove CompareAtributes().
There's no need to exclude directories from search by flags. In fact the Unix backend has worked nicely for years without it... Sadly we can't remove the now superfluous 'canhave' and 'musthave' attributes from Sys_FindFirst() and Sys_FindNext() since they're defined in shared.h and may be used from custom game DLLs.
This commit is contained in:
parent
a65401d1af
commit
e9615608a8
5 changed files with 13 additions and 83 deletions
|
@ -239,17 +239,9 @@ Sys_Nanosleep(int nanosec)
|
|||
|
||||
/* ================================================================ */
|
||||
|
||||
static qboolean
|
||||
CompareAttributes(char *path, char *name, unsigned musthave, unsigned canthave)
|
||||
{
|
||||
/* . and .. never match */
|
||||
if ((strcmp(name, ".") == 0) || (strcmp(name, "..") == 0))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
/* The musthave and canhave arguments are unused in YQ2. We
|
||||
can't remove them since Sys_FindFirst() and Sys_FindNext()
|
||||
are defined in shared.h and may be used in custom game DLLs. */
|
||||
|
||||
char *
|
||||
Sys_FindFirst(char *path, unsigned musthave, unsigned canhave)
|
||||
|
@ -288,7 +280,7 @@ Sys_FindFirst(char *path, unsigned musthave, unsigned canhave)
|
|||
{
|
||||
if (!*findpattern || glob_match(findpattern, d->d_name))
|
||||
{
|
||||
if (CompareAttributes(findbase, d->d_name, musthave, canhave))
|
||||
if ((strcmp(d->d_name, ".") != 0) || (strcmp(d->d_name, "..") != 0))
|
||||
{
|
||||
sprintf(findpath, "%s/%s", findbase, d->d_name);
|
||||
return findpath;
|
||||
|
@ -313,7 +305,7 @@ Sys_FindNext(unsigned musthave, unsigned canhave)
|
|||
{
|
||||
if (!*findpattern || glob_match(findpattern, d->d_name))
|
||||
{
|
||||
if (CompareAttributes(findbase, d->d_name, musthave, canhave))
|
||||
if ((strcmp(d->d_name, ".") != 0) || (strcmp(d->d_name, "..") != 0))
|
||||
{
|
||||
sprintf(findpath, "%s/%s", findbase, d->d_name);
|
||||
return findpath;
|
||||
|
|
|
@ -319,63 +319,12 @@ void Sys_Nanosleep(int nanosec)
|
|||
|
||||
/* ================================================================ */
|
||||
|
||||
/* The musthave and canhave arguments are unused in YQ2. We
|
||||
can't remove them since Sys_FindFirst() and Sys_FindNext()
|
||||
are defined in shared.h and may be used in custom game DLLs. */
|
||||
|
||||
// TODO: Still uses broken DOS functions.
|
||||
// Have a look at FindFirstFile(), FindNextFile() and FindClose().
|
||||
static qboolean
|
||||
CompareAttributes(unsigned found, unsigned musthave, unsigned canthave)
|
||||
{
|
||||
if ((found & _A_RDONLY) && (canthave & SFF_RDONLY))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((found & _A_HIDDEN) && (canthave & SFF_HIDDEN))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((found & _A_SYSTEM) && (canthave & SFF_SYSTEM))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((found & _A_SUBDIR) && (canthave & SFF_SUBDIR))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((found & _A_ARCH) && (canthave & SFF_ARCH))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((musthave & SFF_RDONLY) && !(found & _A_RDONLY))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((musthave & SFF_HIDDEN) && !(found & _A_HIDDEN))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((musthave & SFF_SYSTEM) && !(found & _A_SYSTEM))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((musthave & SFF_SUBDIR) && !(found & _A_SUBDIR))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((musthave & SFF_ARCH) && !(found & _A_ARCH))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
char *
|
||||
Sys_FindFirst(char *path, unsigned musthave, unsigned canthave)
|
||||
|
@ -397,11 +346,6 @@ Sys_FindFirst(char *path, unsigned musthave, unsigned canthave)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (!CompareAttributes(findinfo.attrib, musthave, canthave))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Com_sprintf(findpath, sizeof(findpath), "%s/%s", findbase, findinfo.name);
|
||||
return findpath;
|
||||
}
|
||||
|
@ -421,11 +365,6 @@ Sys_FindNext(unsigned musthave, unsigned canthave)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (!CompareAttributes(findinfo.attrib, musthave, canthave))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Com_sprintf(findpath, sizeof(findpath), "%s/%s", findbase, findinfo.name);
|
||||
return findpath;
|
||||
}
|
||||
|
|
|
@ -3844,7 +3844,7 @@ PlayerConfig_ScanDirectories(void)
|
|||
s_numplayermodels = 0;
|
||||
|
||||
/* get a list of directories */
|
||||
if ((dirnames = FS_ListFiles2("players/*", &ndirs, SFF_SUBDIR, 0)) == NULL)
|
||||
if ((dirnames = FS_ListFiles2("players/*", &ndirs, 0, 0)) == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -3891,7 +3891,7 @@ PlayerConfig_ScanDirectories(void)
|
|||
strcpy(scratch, dirnames[i]);
|
||||
strcat(scratch, "/*.pcx");
|
||||
|
||||
if ((pcxnames = FS_ListFiles2(scratch, &npcxfiles, 0, SFF_SUBDIR | SFF_HIDDEN | SFF_SYSTEM)) == NULL)
|
||||
if ((pcxnames = FS_ListFiles2(scratch, &npcxfiles, 0, 0)) == NULL)
|
||||
{
|
||||
free(dirnames[i]);
|
||||
dirnames[i] = 0;
|
||||
|
|
|
@ -302,8 +302,7 @@ OGG_LoadFileList(void)
|
|||
|
||||
/* Get file list. */
|
||||
list = FS_ListFiles2(va("%s/*.ogg", OGG_DIR),
|
||||
&ogg_numfiles, 0, SFF_SUBDIR | SFF_HIDDEN |
|
||||
SFF_SYSTEM);
|
||||
&ogg_numfiles, 0, 0);
|
||||
ogg_numfiles--;
|
||||
|
||||
/* Check if there are posible Ogg files. */
|
||||
|
|
|
@ -1325,7 +1325,7 @@ FS_AddDirToSearchPath(char *dir, qboolean create) {
|
|||
Com_sprintf(path, sizeof(path), "%s/*.%s", dir, fs_packtypes[i].suffix);
|
||||
|
||||
// Nothing here, next pak type please.
|
||||
if ((list = FS_ListFiles(path, &nfiles, 0, SFF_SUBDIR)) == NULL)
|
||||
if ((list = FS_ListFiles(path, &nfiles, 0, 0)) == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue