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)
|
||||
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)
|
||||
{
|
||||
const char *fileName = GetFileName(filePath); // Get filename.ext without path
|
||||
for (int i = (int)strlen(fileName); i>0; i--) // Reverse search '.'
|
||||
strcpy(fileName, GetFileName(filePath)); // Get filename.ext without path
|
||||
int size = (int)strlen(fileName); // Get size in bytes
|
||||
for (int i = size; i>0; i--) // Reverse search '.'
|
||||
{
|
||||
if (fileName[i] == '.')
|
||||
{
|
||||
char rfileName[i];
|
||||
strncpy(rfileName, fileName,i);
|
||||
rfileName[i] = '\0';
|
||||
const char* rrfileName = rfileName;
|
||||
return rrfileName;
|
||||
fileName[i] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
return fileName; // Extension not found
|
||||
}
|
||||
return "\0";
|
||||
return fileName;
|
||||
}
|
||||
|
||||
// Get directory for a given filePath
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user