From e8def12ba268b7b663df024979f399d32d3dae9d Mon Sep 17 00:00:00 2001 From: James Bursa Date: Fri, 7 Nov 2003 23:47:55 +0000 Subject: [project @ 2003-11-07 23:47:55 by bursa] Add is_dir(). svn path=/import/netsurf/; revision=407 --- utils/utils.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'utils/utils.c') 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 #include #include +#include #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; +} -- cgit v1.2.3