2010-11-18 02:35:33 +01:00
|
|
|
/* See LICENSE file for license and copyright information */
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2010-11-18 03:15:32 +01:00
|
|
|
#include <string.h>
|
2010-11-18 02:35:33 +01:00
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "utils.h"
|
|
|
|
|
|
|
|
bool
|
|
|
|
file_exists(const char* path)
|
|
|
|
{
|
|
|
|
if(!access(path, F_OK)) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char*
|
|
|
|
file_get_extension(const char* path)
|
|
|
|
{
|
2010-11-18 03:15:32 +01:00
|
|
|
if(!path) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int i = strlen(path);
|
|
|
|
for(; i > 0; i--)
|
|
|
|
{
|
|
|
|
if(*(path + i) != '.')
|
|
|
|
continue;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!i) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return path + i + 1;
|
2010-11-18 02:35:33 +01:00
|
|
|
}
|