From 24d1d644179572aaf9ce2e0885a5eb210bd4a386 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 17 Aug 2025 21:31:05 +0200 Subject: [PATCH] REXM: REVIEWED: `ScanExampleResources()` avoid resources to be saved by the program --- tools/rexm/rexm.c | 54 ++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/tools/rexm/rexm.c b/tools/rexm/rexm.c index 206e619c0..c49d6883b 100644 --- a/tools/rexm/rexm.c +++ b/tools/rexm/rexm.c @@ -1802,37 +1802,43 @@ static char **ScanExampleResources(const char *filePath, int *resPathCount) char *end = strchr(start, '"'); if (!end) break; - int len = (int)(end - start); - if ((len > 0) && (len < REXM_MAX_RESOURCE_PATH_LEN)) + // TODO: WARNING: Some paths could be for files to save, not files to load, verify it + // 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 }; - strncpy(buffer, start, len); - buffer[len] = '\0'; + int len = (int)(end - start); + if ((len > 0) && (len < REXM_MAX_RESOURCE_PATH_LEN)) + { + char buffer[REXM_MAX_RESOURCE_PATH_LEN] = { 0 }; + strncpy(buffer, start, len); + buffer[len] = '\0'; - // TODO: Make sure buffer is a path (and not a Tracelog() text) + // 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, - // but in this case buffer can contain any kind of string, - // including not paths strings, for example TraceLog() string - if (IsFileExtension(buffer, exts[i])) + // Check for known extensions + for (int i = 0; i < extCount; i++) { - // Avoid duplicates - bool found = false; - for (int j = 0; j < resCounter; j++) + // TODO: WARNING: IsFileExtension() expects a NULL terminated fileName, + // but in this case buffer can contain any kind of string, + // 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)) - { - strcpy(paths[resCounter], buffer); - resCounter++; - } + if (!found && (resCounter < REXM_MAX_RESOURCE_PATHS)) + { + strcpy(paths[resCounter], buffer); + resCounter++; + } - break; + break; + } } } }