mirror of
https://github.com/NikitaIvanovV/ctpv.git
synced 2024-11-24 13:53:07 +01:00
Fix
This commit is contained in:
parent
9d5c7f144f
commit
00568ce0f6
20
src/utils.c
20
src/utils.c
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user