Fix not closing description.txt and fix path seperator

0 length description.txt files were not closed.
This commit is contained in:
Zack Middleton 2018-05-03 16:03:12 -05:00
parent 51743bbb01
commit da861ff3a2

View file

@ -2491,20 +2491,23 @@ void FS_GetModDescription( const char *modDir, char *description, int descriptio
int nDescLen; int nDescLen;
FILE *file; FILE *file;
Com_sprintf( descPath, sizeof ( descPath ), "%s/description.txt", modDir ); Com_sprintf( descPath, sizeof ( descPath ), "%s%cdescription.txt", modDir, PATH_SEP );
nDescLen = FS_SV_FOpenFileRead( descPath, &descHandle ); nDescLen = FS_SV_FOpenFileRead( descPath, &descHandle );
if ( nDescLen > 0 && descHandle ) { if ( nDescLen > 0 ) {
file = FS_FileForHandle(descHandle); file = FS_FileForHandle(descHandle);
Com_Memset( description, 0, descriptionLen ); Com_Memset( description, 0, descriptionLen );
nDescLen = fread(description, 1, descriptionLen, file); nDescLen = fread(description, 1, descriptionLen, file);
if (nDescLen >= 0) { if (nDescLen >= 0) {
description[nDescLen] = '\0'; description[nDescLen] = '\0';
} }
FS_FCloseFile(descHandle);
} else { } else {
Q_strncpyz( description, modDir, descriptionLen ); Q_strncpyz( description, modDir, descriptionLen );
} }
if ( descHandle ) {
FS_FCloseFile( descHandle );
}
} }
/* /*