summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2003-11-07 23:47:55 +0000
committerJames Bursa <james@netsurf-browser.org>2003-11-07 23:47:55 +0000
commite8def12ba268b7b663df024979f399d32d3dae9d (patch)
tree6ef61f3a691f16c56e85a493f06353649d4a562b
parentb212e59a20f304132e8c6636771d250ac7998ad3 (diff)
downloadnetsurf-e8def12ba268b7b663df024979f399d32d3dae9d.tar.gz
netsurf-e8def12ba268b7b663df024979f399d32d3dae9d.tar.bz2
[project @ 2003-11-07 23:47:55 by bursa]
Add is_dir(). svn path=/import/netsurf/; revision=407
-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