From fa41863b03bbf67a7ad4edad9328b0cdc48e497b Mon Sep 17 00:00:00 2001 From: gramanas Date: Thu, 4 Oct 2018 01:20:13 +0300 Subject: store configs in subfolders and error/logging infrastructure --- src/ckutil.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/ckutil.c') diff --git a/src/ckutil.c b/src/ckutil.c index 880696b..a477b36 100644 --- a/src/ckutil.c +++ b/src/ckutil.c @@ -45,19 +45,28 @@ int util_file_exists(const char* path, char *absPath) { if (stat(path, &st) == -1) { return 0; } - if (absPath != NULL) { + if (absPath) { realpath(path, absPath); } return 1; } -int util_is_file_rw(const char* path) { +int util_is_file_rw(const char *path) { if (access(path, R_OK | W_OK) == 0) { return 1; } return 0; } +int util_is_file_link(const char *path) { + struct stat buf; + lstat(path, &buf); + if (S_ISLNK(buf.st_mode)) { + return 0; + } + return 1; +} + void util_mkdir(const char *name) { mkdir(name, 0755); } -- cgit v1.2.3