Some more vfs changes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1772 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
3140f1f875
commit
b703cf0d85
1 changed files with 70 additions and 5 deletions
|
@ -561,7 +561,12 @@ void VFSPAK_Close(vfsfile_t *vfs)
|
||||||
vfsfile_t *FSPAK_OpenVFS(void *handle, flocation_t *loc, char *mode)
|
vfsfile_t *FSPAK_OpenVFS(void *handle, flocation_t *loc, char *mode)
|
||||||
{
|
{
|
||||||
pack_t *pack = (pack_t*)handle;
|
pack_t *pack = (pack_t*)handle;
|
||||||
vfspack_t *vfs = Z_Malloc(sizeof(vfspack_t));
|
vfspack_t *vfs;
|
||||||
|
|
||||||
|
if (strcmp(mode, "rb"))
|
||||||
|
return NULL; //urm, unable to write/append
|
||||||
|
|
||||||
|
vfs = Z_Malloc(sizeof(vfspack_t));
|
||||||
|
|
||||||
vfs->parentpak = ((pack_t*)handle);
|
vfs->parentpak = ((pack_t*)handle);
|
||||||
vfs->parentpak->references++;
|
vfs->parentpak->references++;
|
||||||
|
@ -943,8 +948,10 @@ vfsfile_t *FSZIP_OpenVFS(void *handle, flocation_t *loc, char *mode)
|
||||||
int rawofs;
|
int rawofs;
|
||||||
zipfile_t *zip = handle;
|
zipfile_t *zip = handle;
|
||||||
vfszip_t *vfsz;
|
vfszip_t *vfsz;
|
||||||
if (strchr(mode, 'w'))
|
|
||||||
return NULL;
|
if (strcmp(mode, "rb"))
|
||||||
|
return NULL; //urm, unable to write/append
|
||||||
|
|
||||||
vfsz = Z_Malloc(sizeof(vfszip_t));
|
vfsz = Z_Malloc(sizeof(vfszip_t));
|
||||||
|
|
||||||
vfsz->parent = zip;
|
vfsz->parent = zip;
|
||||||
|
@ -1164,7 +1171,10 @@ void COM_Locate_f (void)
|
||||||
loc.search->funcs->PrintPath(loc.search->handle);
|
loc.search->funcs->PrintPath(loc.search->handle);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
Con_Printf("Inside %s\n", loc.rawname);
|
Con_Printf("Inside %s\n", loc.rawname);
|
||||||
|
loc.search->funcs->PrintPath(loc.search->handle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Con_Printf("Not found\n");
|
Con_Printf("Not found\n");
|
||||||
|
@ -1426,6 +1436,42 @@ out:
|
||||||
else
|
else
|
||||||
return depth;
|
return depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char *FS_GetPackHashes(char *buffer, int buffersize, qboolean referencedonly)
|
||||||
|
{
|
||||||
|
searchpath_t *search;
|
||||||
|
buffersize--;
|
||||||
|
*buffer = 0;
|
||||||
|
|
||||||
|
if (com_purepaths)
|
||||||
|
{
|
||||||
|
for (search = com_purepaths ; search ; search = search->nextpure)
|
||||||
|
{
|
||||||
|
Q_strncatz(buffer, va("%i ", search->crc_check), buffersize);
|
||||||
|
}
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (search = com_searchpaths ; search ; search = search->next)
|
||||||
|
{
|
||||||
|
if (!search->crc_check && search->funcs->GeneratePureCRC)
|
||||||
|
search->crc_check = search->funcs->GeneratePureCRC(search->handle, 0, 0);
|
||||||
|
if (search->crc_check)
|
||||||
|
{
|
||||||
|
Q_strncatz(buffer, va("%i ", search->crc_check), buffersize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
char *FS_GetPackNames(char *buffer, int buffersize, qboolean referencedonly)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
int COM_FOpenLocationFILE(flocation_t *loc, FILE **file)
|
int COM_FOpenLocationFILE(flocation_t *loc, FILE **file)
|
||||||
{
|
{
|
||||||
|
@ -1524,6 +1570,11 @@ vfsfile_t *FS_OpenVFS(char *filename, char *mode, int relativeto)
|
||||||
if (Sys_PathProtection(filename))
|
if (Sys_PathProtection(filename))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
||||||
|
if (strcmp(mode, "rb"))
|
||||||
|
if (strcmp(mode, "wb"))
|
||||||
|
return NULL; //urm, unable to write/append
|
||||||
|
|
||||||
switch (relativeto)
|
switch (relativeto)
|
||||||
{
|
{
|
||||||
case FS_GAMEONLY: //OS access only, no paks
|
case FS_GAMEONLY: //OS access only, no paks
|
||||||
|
@ -1608,6 +1659,20 @@ void FS_CreatePath(char *pname, int relativeto)
|
||||||
COM_CreatePath(fullname);
|
COM_CreatePath(fullname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qboolean FS_WriteFile (char *filename, void *data, int len, int relativeto)
|
||||||
|
{
|
||||||
|
vfsfile_t *f;
|
||||||
|
FS_CreatePath(filename, relativeto);
|
||||||
|
f = FS_OpenVFS(filename, "wb", relativeto);
|
||||||
|
if (!f)
|
||||||
|
return false;
|
||||||
|
VFS_WRITE(f, data, len);
|
||||||
|
VFS_CLOSE(f);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static cache_user_t *loadcache;
|
static cache_user_t *loadcache;
|
||||||
static qbyte *loadbuf;
|
static qbyte *loadbuf;
|
||||||
static int loadsize;
|
static int loadsize;
|
||||||
|
@ -1633,7 +1698,7 @@ qbyte *COM_LoadFile (char *path, int usehunk)
|
||||||
return NULL; //wasn't found
|
return NULL; //wasn't found
|
||||||
|
|
||||||
|
|
||||||
f = loc.search->funcs->OpenVFS(loc.search->handle, &loc, "r");
|
f = loc.search->funcs->OpenVFS(loc.search->handle, &loc, "rb");
|
||||||
if (!f)
|
if (!f)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -2087,7 +2152,7 @@ static int COM_AddWildDataFiles (char *descriptor, int size, void *vparam)
|
||||||
|
|
||||||
if (!search->funcs->FindFile(search->handle, &loc, descriptor, NULL))
|
if (!search->funcs->FindFile(search->handle, &loc, descriptor, NULL))
|
||||||
return true; //not found..
|
return true; //not found..
|
||||||
vfs = search->funcs->OpenVFS(search->handle, &loc, "r");
|
vfs = search->funcs->OpenVFS(search->handle, &loc, "rb");
|
||||||
pak = funcs->OpenNew (vfs, pakfile);
|
pak = funcs->OpenNew (vfs, pakfile);
|
||||||
if (!pak)
|
if (!pak)
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue