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 ++++++++++++++++ utils/utils.h | 2 ++ 2 files changed, 18 insertions(+) (limited to 'utils') 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; +} 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 #include #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 -- cgit v1.2.3