mirror of
https://github.com/rehlds/rehlds.git
synced 2025-01-28 22:48:05 +03:00
Reworked COM_FileExtension for consider some case.
This commit is contained in:
parent
6520ab54b0
commit
4e4690bd6b
@ -1355,21 +1355,31 @@ void COM_StripExtension(char *in, char *out)
|
|||||||
char *COM_FileExtension(char *in)
|
char *COM_FileExtension(char *in)
|
||||||
{
|
{
|
||||||
#ifdef REHLDS_FIXES
|
#ifdef REHLDS_FIXES
|
||||||
char *src = in + Q_strlen(in) - 1;
|
int len = Q_strlen(in);
|
||||||
|
if (len <= 0)
|
||||||
|
return ""; // no extension
|
||||||
|
|
||||||
|
char *src = in + len - 1;
|
||||||
|
|
||||||
// back up until a . or the start
|
// back up until a . or the start
|
||||||
while (src != in && *(src - 1) != '.')
|
while (src >= in && !PATHSEPARATOR(*src))
|
||||||
{
|
{
|
||||||
|
if (*src == '.')
|
||||||
|
{
|
||||||
|
src++; // skip dot
|
||||||
|
|
||||||
|
if (*src != '\0')
|
||||||
|
{
|
||||||
|
return src;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
src--;
|
src--;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check to see if the '.' is part of a input buffer
|
return ""; // no extension
|
||||||
if (src == in || PATHSEPARATOR(*src))
|
|
||||||
{
|
|
||||||
return ""; // no extension
|
|
||||||
}
|
|
||||||
|
|
||||||
return src;
|
|
||||||
#else // #ifdef REHLDS_FIXES
|
#else // #ifdef REHLDS_FIXES
|
||||||
static char exten[MAX_PATH];
|
static char exten[MAX_PATH];
|
||||||
char *c, *d = NULL;
|
char *c, *d = NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user