aboutsummaryrefslogtreecommitdiff
path: root/src/path.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/path.c')
-rw-r--r--src/path.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/path.c b/src/path.c
index e2751a9..6177278 100644
--- a/src/path.c
+++ b/src/path.c
@@ -59,6 +59,22 @@ bool pw_stripext(char *name, size_t sz, char const *path, char const *ext) {
return true;
}
+bool pw_hasext(char const *path, char const *ext) {
+ if (!path) {
+ SDL_InvalidParamError("path");
+ return false;
+ }
+ if (!ext) {
+ SDL_InvalidParamError("ext");
+ return false;
+ }
+
+ size_t plen = SDL_strlen(path);
+ size_t elen = SDL_strlen(ext);
+ size_t nlen = plen - elen;
+ return plen >= elen && !SDL_strcasecmp(path + nlen, ext);
+}
+
bool pw_pathjoin(char *path, size_t sz, ...) {
if (!path) {
SDL_InvalidParamError("path");