mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-10 15:31:39 +00:00
replaced COM_FileExtension by a slightly better version from uhexen2,
renamed it to COM_FileGetExtension, added a prototype to common.h. git-svn-id: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@454 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
99bbf85535
commit
5d43920b02
2 changed files with 15 additions and 12 deletions
|
@ -919,23 +919,25 @@ void COM_StripExtension (const char *in, char *out)
|
|||
|
||||
/*
|
||||
============
|
||||
COM_FileExtension
|
||||
COM_FileGetExtension - doesn't return NULL
|
||||
============
|
||||
*/
|
||||
const char *COM_FileExtension (const char *in)
|
||||
const char *COM_FileGetExtension (const char *in)
|
||||
{
|
||||
static char exten[8];
|
||||
int i;
|
||||
const char *src;
|
||||
size_t len;
|
||||
|
||||
while (*in && *in != '.')
|
||||
in++;
|
||||
if (!*in)
|
||||
len = strlen(in);
|
||||
if (len < 2) /* nothing meaningful */
|
||||
return "";
|
||||
in++;
|
||||
for (i=0 ; i<7 && *in ; i++,in++)
|
||||
exten[i] = *in;
|
||||
exten[i] = 0;
|
||||
return exten;
|
||||
|
||||
src = in + len - 1;
|
||||
while (src != in && src[-1] != '.')
|
||||
src--;
|
||||
if (src == in || strchr(src, '/') != NULL || strchr(src, '\\') != NULL)
|
||||
return ""; /* no extension, or parent directory has a dot */
|
||||
|
||||
return src;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -178,6 +178,7 @@ const char *COM_SkipPath (const char *pathname);
|
|||
void COM_StripExtension (const char *in, char *out);
|
||||
void COM_FileBase (const char *in, char *out);
|
||||
void COM_DefaultExtension (char *path, const char *extension);
|
||||
const char *COM_FileGetExtension (const char *in);
|
||||
void COM_CreatePath (char *path);
|
||||
|
||||
char *va (const char *format, ...) __attribute__((__format__(__printf__,1,2)));
|
||||
|
|
Loading…
Reference in a new issue