X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=fs.c;h=2a5ea5a867f3cdbcc5fd4456ba42a42ef3a42593;hp=8ba6759bbc5051ab3c297bbfd80995ec673673a2;hb=5fc362d5d72a0aecbd5a64520b105650f8f2d794;hpb=3f1b692100923a2339f569d3eac738647c4cc90a diff --git a/fs.c b/fs.c index 8ba6759b..2a5ea5a8 100644 --- a/fs.c +++ b/fs.c @@ -679,7 +679,7 @@ static packfile_t* FS_AddFileToPack (const char* name, pack_t* pack, ============ FS_CreatePath -Only used for FS_WriteFile. +Only used for FS_Open. ============ */ void FS_CreatePath (char *path) @@ -1103,9 +1103,8 @@ static searchpath_t *FS_FindFile (const char *name, int* index, qboolean quiet) } else { - char* netpath; - - netpath = va ("%s/%s", search->filename, name); + char netpath[MAX_OSPATH]; + snprintf(netpath, sizeof(netpath), "%s/%s", search->filename, name); if (FS_SysFileExists (netpath)) { if (!quiet) @@ -1155,7 +1154,11 @@ qfile_t *FS_FOpenFile (const char *filename, qboolean quiet) // Found in the filesystem? if (i < 0) - return FS_OpenRead (va ("%s/%s", search->filename, filename), -1, -1); + { + char netpath[MAX_OSPATH]; + snprintf(netpath, sizeof(netpath), "%s/%s", search->filename, filename); + return FS_OpenRead(netpath, -1, -1); + } // So, we found it in a package... packfile = &search->pack->files[i]; @@ -1341,12 +1344,13 @@ size_t FS_Read (qfile_t* file, void* buffer, size_t buffersize) // If "input" is also empty, we need to fill it if (ztk->in_ind == ztk->in_max) { - size_t remain = file->length - ztk->in_position; + size_t remain; // If we are at the end of the file - if (!remain) + if (ztk->out_position == ztk->real_length) return nb; + remain = file->length - ztk->in_position; count = (remain > sizeof (ztk->input)) ? sizeof (ztk->input) : remain; fread (ztk->input, 1, count, file->stream);