mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-01-26 02:40:57 +00:00
Implement system depended file handling
Those functions were taken from ioQuake2 and refactored to match Yamagi Quake II.
This commit is contained in:
parent
2205d54a41
commit
1d77f68c22
1 changed files with 132 additions and 0 deletions
|
@ -57,6 +57,10 @@ unsigned int sys_frame_time;
|
|||
static char console_text[256];
|
||||
static int console_textlen;
|
||||
|
||||
char findbase[MAX_OSPATH];
|
||||
char findpath[MAX_OSPATH];
|
||||
int findhandle;
|
||||
|
||||
int argc;
|
||||
char *argv[MAX_NUM_ARGVS];
|
||||
|
||||
|
@ -506,6 +510,134 @@ Sys_Milliseconds(void)
|
|||
|
||||
/* ======================================================================= */
|
||||
|
||||
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)
|
||||
{
|
||||
struct _finddata_t findinfo;
|
||||
|
||||
if (findhandle)
|
||||
{
|
||||
Sys_Error("Sys_BeginFind without close");
|
||||
}
|
||||
|
||||
findhandle = 0;
|
||||
|
||||
COM_FilePath(path, findbase);
|
||||
findhandle = _findfirst(path, &findinfo);
|
||||
|
||||
if (findhandle == -1)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!CompareAttributes(findinfo.attrib, musthave, canthave))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Com_sprintf(findpath, sizeof(findpath), "%s/%s", findbase, findinfo.name);
|
||||
return findpath;
|
||||
}
|
||||
|
||||
char *
|
||||
Sys_FindNext(unsigned musthave, unsigned canthave)
|
||||
{
|
||||
struct _finddata_t findinfo;
|
||||
|
||||
if (findhandle == -1)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (_findnext(findhandle, &findinfo) == -1)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!CompareAttributes(findinfo.attrib, musthave, canthave))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Com_sprintf(findpath, sizeof(findpath), "%s/%s", findbase, findinfo.name);
|
||||
return findpath;
|
||||
}
|
||||
|
||||
void
|
||||
Sys_FindClose(void)
|
||||
{
|
||||
if (findhandle != -1)
|
||||
{
|
||||
_findclose(findhandle);
|
||||
}
|
||||
|
||||
findhandle = 0;
|
||||
}
|
||||
|
||||
void
|
||||
Sys_Mkdir(char *path)
|
||||
{
|
||||
_mkdir(path);
|
||||
}
|
||||
|
||||
/* ======================================================================= */
|
||||
|
||||
/*
|
||||
* Windows main function. Containts the
|
||||
* initialization code and the main loop
|
||||
|
|
Loading…
Reference in a new issue