Update rcore.c

This commit is contained in:
oblerion 2024-02-03 19:43:31 +01:00 committed by GitHub
parent 780ed34508
commit a64b9f3be9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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