diff options
Diffstat (limited to 'lib/isc/include/isc/file.h')
-rw-r--r-- | lib/isc/include/isc/file.h | 56 |
1 files changed, 52 insertions, 4 deletions
diff --git a/lib/isc/include/isc/file.h b/lib/isc/include/isc/file.h index c9457343e055..5db506a389a4 100644 --- a/lib/isc/include/isc/file.h +++ b/lib/isc/include/isc/file.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2007, 2009, 2011, 2012 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000, 2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: file.h,v 1.33.332.2 2009/01/18 23:47:41 tbox Exp $ */ +/* $Id$ */ #ifndef ISC_FILE_H #define ISC_FILE_H 1 @@ -30,10 +30,10 @@ ISC_LANG_BEGINDECLS isc_result_t -isc_file_settime(const char *file, isc_time_t *time); +isc_file_settime(const char *file, isc_time_t *itime); isc_result_t -isc_file_getmodtime(const char *file, isc_time_t *time); +isc_file_getmodtime(const char *file, isc_time_t *itime); /*!< * \brief Get the time of last modification of a file. * @@ -100,6 +100,10 @@ isc_file_mktemplate(const char *path, char *buf, size_t buflen); isc_result_t isc_file_openunique(char *templet, FILE **fp); +isc_result_t +isc_file_openuniqueprivate(char *templet, FILE **fp); +isc_result_t +isc_file_openuniquemode(char *templet, int mode, FILE **fp); /*!< * \brief Create and open a file with a unique name based on 'templet'. * @@ -181,6 +185,27 @@ isc_file_isabsolute(const char *filename); * \brief Return #ISC_TRUE if the given file name is absolute. */ +isc_result_t +isc_file_isplainfile(const char *name); +/*!< + * \brief Check that the file is a plain file + * + * Returns: + *\li #ISC_R_SUCCESS + * Success. The file is a plain file. + *\li #ISC_R_INVALIDFILE + * The path specified was not usable by the operating system. + *\li #ISC_R_FILENOTFOUND + * The file does not exist. This return code comes from + * errno=ENOENT when stat returns -1. This code is mentioned + * here, because in logconf.c, it is the one rcode that is + * permitted in addition to ISC_R_SUCCESS. This is done since + * the next call in logconf.c is to isc_stdio_open(), which + * will create the file if it can. + *\li #other ISC_R_* errors translated from errno + * These occur when stat returns -1 and an errno. + */ + isc_boolean_t isc_file_iscurrentdir(const char *filename); /*!< @@ -251,6 +276,29 @@ isc_file_truncate(const char *filename, isc_offset_t size); * Truncate/extend the file specified to 'size' bytes. */ +isc_result_t +isc_file_safecreate(const char *filename, FILE **fp); +/*%< + * Open 'filename' for writing, truncating if necessary. Ensure that + * if it existed it was a normal file. If creating the file, ensure + * that only the owner can read/write it. + */ + +isc_result_t +isc_file_splitpath(isc_mem_t *mctx, char *path, + char **dirname, char **basename); +/*%< + * Split a path into dirname and basename. If 'path' contains no slash + * (or, on windows, backslash), then '*dirname' is set to ".". + * + * Allocates memory for '*dirname', which can be freed with isc_mem_free(). + * + * Returns: + * - ISC_R_SUCCESS on success + * - ISC_R_INVALIDFILE if 'path' is empty or ends with '/' + * - ISC_R_NOMEMORY if unable to allocate memory + */ + ISC_LANG_ENDDECLS #endif /* ISC_FILE_H */ |