diff options
Diffstat (limited to 'lib/isc/unix/file.c')
-rw-r--r-- | lib/isc/unix/file.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/isc/unix/file.c b/lib/isc/unix/file.c index eac60361851fb..8f55c60958051 100644 --- a/lib/isc/unix/file.c +++ b/lib/isc/unix/file.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2009, 2011 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -48,7 +48,7 @@ * SUCH DAMAGE. */ -/* $Id: file.c,v 1.47.18.4 2009-02-16 23:46:03 tbox Exp $ */ +/* $Id: file.c,v 1.47.18.6 2011-03-05 23:47:52 tbox Exp $ */ /*! \file */ @@ -338,6 +338,23 @@ isc_file_exists(const char *pathname) { return (ISC_TF(file_stats(pathname, &stats) == ISC_R_SUCCESS)); } +isc_result_t +isc_file_isplainfile(const char *filename) { + /* + * This function returns success if filename is a plain file. + */ + struct stat filestat; + memset(&filestat,0,sizeof(struct stat)); + + if ((stat(filename, &filestat)) == -1) + return(isc__errno2result(errno)); + + if(! S_ISREG(filestat.st_mode)) + return(ISC_R_INVALIDFILE); + + return(ISC_R_SUCCESS); +} + isc_boolean_t isc_file_isabsolute(const char *filename) { REQUIRE(filename != NULL); |