mirror of
https://github.com/raysan5/raylib.git
synced 2026-01-18 13:41:26 +01:00
REXM: REVIEWED: ScanExampleResources() avoid resources to be saved by the program
This commit is contained in:
@ -1802,37 +1802,43 @@ static char **ScanExampleResources(const char *filePath, int *resPathCount)
|
|||||||
char *end = strchr(start, '"');
|
char *end = strchr(start, '"');
|
||||||
if (!end) break;
|
if (!end) break;
|
||||||
|
|
||||||
int len = (int)(end - start);
|
// TODO: WARNING: Some paths could be for files to save, not files to load, verify it
|
||||||
if ((len > 0) && (len < REXM_MAX_RESOURCE_PATH_LEN))
|
// HACK: Just check previous position from pointer for function name including the string...
|
||||||
|
// This is a horrible solution, the good one would be getting the data loading function names...
|
||||||
|
if (TextFindIndex(ptr - 40, "ExportImage") == -1)
|
||||||
{
|
{
|
||||||
char buffer[REXM_MAX_RESOURCE_PATH_LEN] = { 0 };
|
int len = (int)(end - start);
|
||||||
strncpy(buffer, start, len);
|
if ((len > 0) && (len < REXM_MAX_RESOURCE_PATH_LEN))
|
||||||
buffer[len] = '\0';
|
|
||||||
|
|
||||||
// TODO: Make sure buffer is a path (and not a Tracelog() text)
|
|
||||||
|
|
||||||
// Check for known extensions
|
|
||||||
for (int i = 0; i < extCount; i++)
|
|
||||||
{
|
{
|
||||||
// TODO: WARNING: IsFileExtension() expects a NULL terminated fileName,
|
char buffer[REXM_MAX_RESOURCE_PATH_LEN] = { 0 };
|
||||||
// but in this case buffer can contain any kind of string,
|
strncpy(buffer, start, len);
|
||||||
// including not paths strings, for example TraceLog() string
|
buffer[len] = '\0';
|
||||||
if (IsFileExtension(buffer, exts[i]))
|
|
||||||
|
// TODO: Make sure buffer is a path (and not a Tracelog() text)
|
||||||
|
|
||||||
|
// Check for known extensions
|
||||||
|
for (int i = 0; i < extCount; i++)
|
||||||
{
|
{
|
||||||
// Avoid duplicates
|
// TODO: WARNING: IsFileExtension() expects a NULL terminated fileName,
|
||||||
bool found = false;
|
// but in this case buffer can contain any kind of string,
|
||||||
for (int j = 0; j < resCounter; j++)
|
// including not paths strings, for example TraceLog() string
|
||||||
|
if (IsFileExtension(buffer, exts[i]))
|
||||||
{
|
{
|
||||||
if (strcmp(paths[j], buffer) == 0) { found = true; break; }
|
// Avoid duplicates
|
||||||
}
|
bool found = false;
|
||||||
|
for (int j = 0; j < resCounter; j++)
|
||||||
|
{
|
||||||
|
if (strcmp(paths[j], buffer) == 0) { found = true; break; }
|
||||||
|
}
|
||||||
|
|
||||||
if (!found && (resCounter < REXM_MAX_RESOURCE_PATHS))
|
if (!found && (resCounter < REXM_MAX_RESOURCE_PATHS))
|
||||||
{
|
{
|
||||||
strcpy(paths[resCounter], buffer);
|
strcpy(paths[resCounter], buffer);
|
||||||
resCounter++;
|
resCounter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user