Update rcore.c
fix [rcore] GetFileNameWithoutExt
This commit is contained in:
parent
25306eae42
commit
5cef881ae6
21
src/rcore.c
21
src/rcore.c
|
|
@ -1946,26 +1946,17 @@ 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
|
const char *filename = GetFileName(filePath);
|
||||||
|
int pos = TextLength(filename);
|
||||||
static char fileName[MAX_FILENAMEWITHOUTEXT_LENGTH] = { 0 };
|
for(int i = pos; i>0; i--)
|
||||||
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 (fileName[i] == '.')
|
if(filename[i] == '.')
|
||||||
{
|
{
|
||||||
// NOTE: We break on first '.' found
|
pos = i;
|
||||||
fileName[i] = '\0';
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return TextSubtext(filename,0,pos);
|
||||||
return fileName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get directory for a given filePath
|
// Get directory for a given filePath
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user