Skip to content
Merged
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions src/rcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -1946,26 +1946,23 @@ 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) strcpy(fileName, GetFileName(filePath)); // Get filename with extension

int size = (int)strlen(fileName); // Get size in bytes

for (int i = 0; (i < size) && (i < MAX_FILENAMEWITHOUTEXT_LENGTH); i++)
if (filePath != NULL)
{
if (fileName[i] == '.')
const char *fileName = GetFileName(filePath); // Get filename.ext without path
for (int i = (int)strlen(fileName); i>0; i--) // Reverse search '.'
{
// NOTE: We break on first '.' found
fileName[i] = '\0';
break;
if (fileName[i] == '.')
{
char rfileName[i];
strncpy(rfileName, fileName,i);
rfileName[i] = '\0';
const char* rrfileName = rfileName;
return rrfileName;
}
}
return fileName; // Extension not found
}

return fileName;
return "\0";
}

// Get directory for a given filePath
Expand Down