file.c: moved everything into path.c
This commit is contained in:
parent
c1963d1397
commit
f65dcaaf18
6 changed files with 13 additions and 19 deletions
|
|
@ -22,6 +22,7 @@
|
|||
#include "notify.h"
|
||||
#include "database.h"
|
||||
#include "util.h"
|
||||
#include "path.h"
|
||||
#include "debug.h"
|
||||
|
||||
static dictionary *config = NULL;
|
||||
|
|
@ -30,7 +31,7 @@ static int load_config(const char *file) {
|
|||
|
||||
iniparser_freedict(config);
|
||||
|
||||
if (file_exists(file)) {
|
||||
if (is_file(file)) {
|
||||
config = iniparser_load(file);
|
||||
if (NULL == config)
|
||||
return -1;
|
||||
|
|
|
|||
15
src/file.c
15
src/file.c
|
|
@ -1,15 +0,0 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include "util.h"
|
||||
|
||||
int file_exists(const char *path) {
|
||||
|
||||
struct stat st;
|
||||
|
||||
if (stat(path, &st) < 0)
|
||||
return 0;
|
||||
|
||||
return S_ISREG(st.st_mode);
|
||||
}
|
||||
|
|
@ -58,6 +58,15 @@ int is_abspath(const char *path) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int is_file(const char *path) {
|
||||
|
||||
struct stat st;
|
||||
|
||||
if (path && stat(path, &st) >= 0)
|
||||
return S_ISREG(st.st_mode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int is_dir(const char *path) {
|
||||
|
||||
struct stat st;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
int is_abspath(const char *path);
|
||||
|
||||
int is_file(const char *path);
|
||||
|
||||
int is_dir(const char *path);
|
||||
|
||||
char* path_normalize(const char *base, const char *name, unsigned char dir);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,4 @@ void die(const char *, ...);
|
|||
|
||||
void die_errno(const char *);
|
||||
|
||||
int file_exists(const char *);
|
||||
|
||||
#endif /* __UTIL_H */
|
||||
|
|
|
|||
Reference in a new issue