diff options
author | Erwin Lansing <erwin@FreeBSD.org> | 2013-07-24 07:12:55 +0000 |
---|---|---|
committer | Erwin Lansing <erwin@FreeBSD.org> | 2013-07-24 07:12:55 +0000 |
commit | 6f34f6a389ca8199c4b20c17f62d7d924baef7fb (patch) | |
tree | e392027bf54f7a1fd2a6f3a16ecb4487844b44e9 /lib/isc/unix/file.c | |
parent | 650b026006ec14e630f658a0f877099ec38b660b (diff) |
Notes
Diffstat (limited to 'lib/isc/unix/file.c')
-rw-r--r-- | lib/isc/unix/file.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/isc/unix/file.c b/lib/isc/unix/file.c index 99c02ec7b628..7bb25d725f07 100644 --- a/lib/isc/unix/file.c +++ b/lib/isc/unix/file.c @@ -396,6 +396,24 @@ isc_file_isplainfile(const char *filename) { return(ISC_R_SUCCESS); } +isc_result_t +isc_file_isdirectory(const char *filename) { + /* + * This function returns success if filename exists and is a + * directory. + */ + struct stat filestat; + memset(&filestat,0,sizeof(struct stat)); + + if ((stat(filename, &filestat)) == -1) + return(isc__errno2result(errno)); + + if(! S_ISDIR(filestat.st_mode)) + return(ISC_R_INVALIDFILE); + + return(ISC_R_SUCCESS); +} + isc_boolean_t isc_file_isabsolute(const char *filename) { REQUIRE(filename != NULL); @@ -542,6 +560,9 @@ isc_file_splitpath(isc_mem_t *mctx, char *path, char **dirname, char **basename) { char *dir, *file, *slash; + if (path == NULL) + return (ISC_R_INVALIDFILE); + slash = strrchr(path, '/'); if (slash == path) { |