Fixes, improvements

This commit is contained in:
Nikita Ivanov
2022-06-08 09:03:40 +05:00
parent 154a0bfd41
commit 1651ae8df9
8 changed files with 81 additions and 44 deletions

16
utils.c
View File

@ -130,3 +130,19 @@ int mkpath(char* file_path, mode_t mode)
return 0;
}
const char *get_ext(const char *path)
{
const char *base;
if ((base = strrchr(path, '/')))
base += sizeof(*base);
else
base = path;
const char *dot = strchr(base, '.');
if (!dot || dot == base)
return NULL;
return &dot[1];
}