Use strrchr in file_get_extension

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
Sebastian Ramacher 2013-05-04 19:33:14 +02:00
parent 5bc7c7212d
commit 7ebf15543b

16
utils.c
View file

@ -29,24 +29,16 @@
const char*
file_get_extension(const char* path)
{
if (!path) {
if (path == NULL) {
return NULL;
}
unsigned int i = strlen(path);
for (; i > 0; i--) {
if (*(path + i) != '.') {
continue;
} else {
break;
}
}
if (!i) {
const char* res = strrchr(path, '.');
if (res == NULL) {
return NULL;
}
return path + i + 1;
return res + 1;
}
bool