path.c: Added is_dir function
This commit is contained in:
parent
dd0f1ae393
commit
fca8bba289
3 changed files with 21 additions and 0 deletions
11
src/path.c
11
src/path.c
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "strbuf.h"
|
||||
|
|
@ -56,6 +58,15 @@ int is_abspath(const char *path) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int is_dir(const char *path) {
|
||||
|
||||
struct stat st;
|
||||
|
||||
if (path && stat(path, &st) >= 0)
|
||||
return S_ISDIR(st.st_mode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char* expand_home() {
|
||||
|
||||
char *home = getenv("HOME");
|
||||
|
|
|
|||
Reference in a new issue