This commit is contained in:
Nikita Ivanov 2022-06-12 22:32:57 +05:00
parent 9d5c7f144f
commit 00568ce0f6
No known key found for this signature in database
GPG Key ID: 6E656AC5B97B5133

View File

@ -1,3 +1,4 @@
#include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -144,16 +145,17 @@ int mkpath(char* file_path, mode_t mode)
const char *get_ext(const char *path) const char *get_ext(const char *path)
{ {
const char *base; const char *dot = NULL, *s = path + strlen(path) - 1;
if ((base = strrchr(path, '/'))) for (; ; s--) {
base++; if (*s == '.') {
else dot = s + 1;
base = path; continue;
}
const char *dot = strchr(base, '.'); if (!isalnum(*s) || s == path)
if (!dot || dot == base) break;
return NULL; }
return &dot[1]; return dot;
} }