summaryrefslogtreecommitdiffhomepage
path: root/src/core.c
diff options
context:
space:
mode:
authorRay <[email protected]>2019-10-11 20:13:11 +0200
committerRay <[email protected]>2019-10-11 20:13:11 +0200
commit7baa2975ec616bf334fdc4858703896d41589385 (patch)
tree9f0f32a261f0c62445e5f15a0ae5f247d1e26bfd /src/core.c
parente0cb892d2d2d9d1c95f5f0622f1f8237ee843f45 (diff)
downloadraylib-7baa2975ec616bf334fdc4858703896d41589385.tar.gz
raylib-7baa2975ec616bf334fdc4858703896d41589385.zip
REDESIGNED: IsFileExtension()
Now it accepts a ';' separated list of extensions, useful to check multiple extensions
Diffstat (limited to 'src/core.c')
-rw-r--r--src/core.c29
1 files changed, 9 insertions, 20 deletions
diff --git a/src/core.c b/src/core.c
index 305eb33c..40c48f42 100644
--- a/src/core.c
+++ b/src/core.c
@@ -1796,29 +1796,18 @@ bool FileExists(const char *fileName)
bool IsFileExtension(const char *fileName, const char *ext)
{
bool result = false;
- const char *fileExt;
-
- if ((fileExt = strrchr(fileName, '.')) != NULL)
+ const char *fileExt = GetExtension(fileName);
+
+ int extCount = 0;
+ const char **checkExts = TextSplit(ext, ';', &extCount);
+
+ for (int i = 0; i < extCount; i++)
{
-#if defined(_WIN32)
- result = true;
- int extLen = strlen(ext);
-
- if (strlen(fileExt) == extLen)
+ if (strcmp(fileExt, checkExts[i] + 1) == 0)
{
- for (int i = 0; i < extLen; i++)
- {
- if (tolower(fileExt[i]) != tolower(ext[i]))
- {
- result = false;
- break;
- }
- }
+ result = true;
+ break;
}
- else result = false;
-#else
- if (strcmp(fileExt, ext) == 0) result = true;
-#endif
}
return result;