Update rcore.c
This commit is contained in:
parent
780ed34508
commit
a64b9f3be9
20
src/rcore.c
20
src/rcore.c
|
|
@ -1946,23 +1946,25 @@ const char *GetFileName(const char *filePath)
|
||||||
// Get filename string without extension (uses static string)
|
// Get filename string without extension (uses static string)
|
||||||
const char *GetFileNameWithoutExt(const char *filePath)
|
const char *GetFileNameWithoutExt(const char *filePath)
|
||||||
{
|
{
|
||||||
|
#define MAX_FILENAMEWITHOUTEXT_LENGTH 256
|
||||||
|
|
||||||
|
static char fileName[MAX_FILENAMEWITHOUTEXT_LENGTH] = { 0 };
|
||||||
|
memset(fileName, 0, MAX_FILENAMEWITHOUTEXT_LENGTH);
|
||||||
|
|
||||||
if (filePath != NULL)
|
if (filePath != NULL)
|
||||||
{
|
{
|
||||||
const char *fileName = GetFileName(filePath); // Get filename.ext without path
|
strcpy(fileName, GetFileName(filePath)); // Get filename.ext without path
|
||||||
for (int i = (int)strlen(fileName); i>0; i--) // Reverse search '.'
|
int size = (int)strlen(fileName); // Get size in bytes
|
||||||
|
for (int i = size; i>0; i--) // Reverse search '.'
|
||||||
{
|
{
|
||||||
if (fileName[i] == '.')
|
if (fileName[i] == '.')
|
||||||
{
|
{
|
||||||
char rfileName[i];
|
fileName[i] = '\0';
|
||||||
strncpy(rfileName, fileName,i);
|
break;
|
||||||
rfileName[i] = '\0';
|
|
||||||
const char* rrfileName = rfileName;
|
|
||||||
return rrfileName;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fileName; // Extension not found
|
|
||||||
}
|
}
|
||||||
return "\0";
|
return fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get directory for a given filePath
|
// Get directory for a given filePath
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user