mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-06 03:18:14 +00:00
Check for category on new name
This commit is contained in:
@@ -281,6 +281,20 @@ int main(int argc, char *argv[])
|
||||
// Verify example exists in collection to be removed
|
||||
char *exColInfo = LoadFileText(exCollectionFilePath);
|
||||
if (TextFindIndex(exColInfo, argv[2]) != -1) // Example in the collection
|
||||
{
|
||||
// Security checks for new file name to verify category is included
|
||||
int newCatIndex = TextFindIndex(argv[3], "_");
|
||||
if (newCatIndex > 3)
|
||||
{
|
||||
char cat[12] = { 0 };
|
||||
strncpy(cat, argv[3], newCatIndex);
|
||||
bool newCatFound = false;
|
||||
for (int i = 0; i < REXM_MAX_EXAMPLE_CATEGORIES; i++)
|
||||
{
|
||||
if (TextIsEqual(cat, exCategories[i])) { newCatFound = true; break; }
|
||||
}
|
||||
|
||||
if (newCatFound)
|
||||
{
|
||||
strcpy(exName, argv[2]); // Register example name
|
||||
strncpy(exCategory, exName, TextFindIndex(exName, "_"));
|
||||
@@ -288,6 +302,10 @@ int main(int argc, char *argv[])
|
||||
strncpy(exRecategory, exRename, TextFindIndex(exRename, "_"));
|
||||
opCode = OP_RENAME;
|
||||
}
|
||||
else LOG("WARNING: Example new category is not valid\n");
|
||||
}
|
||||
else LOG("WARNING: Example new name does not include category\n");
|
||||
}
|
||||
else LOG("WARNING: RENAME: Example not available in the collection\n");
|
||||
UnloadFileText(exColInfo);
|
||||
}
|
||||
|
Reference in New Issue
Block a user