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 <stdlib.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 *base;
const char *dot = NULL, *s = path + strlen(path) - 1;
if ((base = strrchr(path, '/')))
base++;
else
base = path;
for (; ; s--) {
if (*s == '.') {
dot = s + 1;
continue;
}
const char *dot = strchr(base, '.');
if (!dot || dot == base)
return NULL;
if (!isalnum(*s) || s == path)
break;
}
return &dot[1];
return dot;
}