diff --git a/gcache.c b/gcache.c index 93a0f07..3dff510 100644 --- a/gcache.c +++ b/gcache.c @@ -1,19 +1,9 @@ #include #include #include -#include -#include #include #include "gcache.h" - -static int is_directory(char *path) -{ - struct stat sb; - - if (stat(path, &sb) != 0) - return (0); - return (S_ISDIR(sb.st_mode)); -} +#include "util.h" struct gcache *gcache_open(char *path, int rdonly) { diff --git a/util.c b/util.c index a7c6387..20c4794 100644 --- a/util.c +++ b/util.c @@ -3,11 +3,23 @@ #include #include #include "util.h" +#include +#include +#include #ifndef LINESIZE # define LINESIZE 8192 #endif +int is_directory(char *path) +{ + struct stat sb; + + if (stat(path, &sb) != 0) + return (0); + return (S_ISDIR(sb.st_mode)); +} + const char *isotime(time_t t) { static char buf[] = "YYYY-MM-DDTHH:MM:SSZ"; diff --git a/util.h b/util.h index 5bb3428..e215a69 100644 --- a/util.h +++ b/util.h @@ -9,6 +9,7 @@ #include #include "json.h" +int is_directory(char *path); const char *isotime(time_t t); char *slurp_file(char *filename, int fold_newlines); int json_copy_to_object(JsonNode *obj, JsonNode * object_or_array, int clobber);