summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/utils.c16
-rw-r--r--utils/utils.h2
2 files changed, 18 insertions, 0 deletions
diff --git a/utils/utils.c b/utils/utils.c
index ca7d7f2fc..8fcbc7f44 100644
--- a/utils/utils.c
+++ b/utils/utils.c
@@ -11,6 +11,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <sys/stat.h>
#include "libxml/encoding.h"
#include "libxml/uri.h"
#include "netsurf/utils/log.h"
@@ -275,3 +276,18 @@ char *get_host_from_url (char *url) {
return host;
}
+
+
+/**
+ * Check if a directory exists.
+ */
+
+bool is_dir(const char *path)
+{
+ struct stat s;
+
+ if (stat(path, &s))
+ return false;
+
+ return S_ISDIR(s.st_mode) ? true : false;
+}
diff --git a/utils/utils.h b/utils/utils.h
index 30050b0ae..fb6255511 100644
--- a/utils/utils.h
+++ b/utils/utils.h
@@ -8,6 +8,7 @@
#ifndef _NETSURF_UTILS_UTILS_H_
#define _NETSURF_UTILS_UTILS_H_
+#include <stdbool.h>
#include <stdlib.h>
#include "libxml/encoding.h"
@@ -25,5 +26,6 @@ char * tolat1_pre(xmlChar * s);
char *squash_tolat1(xmlChar *s);
char *url_join(const char* new, const char* base);
char *get_host_from_url(char* url);
+bool is_dir(const char *path);
#endif