893. [func] Removed isc_file_test() and added isc_file_exists()
for the basic functionality that was being added with isc_file_test().
This commit is contained in:
4
CHANGES
4
CHANGES
@@ -1,4 +1,8 @@
|
||||
|
||||
893. [func] Removed isc_file_test() and added isc_file_exists()
|
||||
for the basic functionality that was being added
|
||||
with isc_file_test().
|
||||
|
||||
892. [placeholder]
|
||||
|
||||
891. [bug] Return an error when a SIG(0) signed response to
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: rndc.c,v 1.62 2001/05/31 10:42:49 tale Exp $ */
|
||||
/* $Id: rndc.c,v 1.63 2001/06/08 21:53:47 tale Exp $ */
|
||||
|
||||
/*
|
||||
* Principal Author: DCL
|
||||
@@ -351,10 +351,10 @@ parse_config(isc_mem_t *mctx, isc_log_t *log, cfg_parser_t **pctxp,
|
||||
isc_result_t result;
|
||||
const char *conffile = admin_conffile;
|
||||
|
||||
if (! isc_file_test(conffile, ISC_FILE_EXISTS)) {
|
||||
if (! isc_file_exists(conffile)) {
|
||||
conffile = auto_conffile;
|
||||
|
||||
if (! isc_file_test(conffile, ISC_FILE_EXISTS))
|
||||
if (! isc_file_exists(conffile))
|
||||
fatal("neither %s nor %s was found",
|
||||
admin_conffile, auto_conffile);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: file.h,v 1.19 2001/05/31 10:53:13 tale Exp $ */
|
||||
/* $Id: file.h,v 1.20 2001/06/08 21:53:48 tale Exp $ */
|
||||
|
||||
#ifndef ISC_FILE_H
|
||||
#define ISC_FILE_H 1
|
||||
@@ -25,39 +25,6 @@
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
/*
|
||||
* Definitions for the isc_file_test() 'what' argument.
|
||||
*
|
||||
* Notes:
|
||||
* ISC_FILE_EXISTS tests for existence, but not type. It can fail
|
||||
* if the user does not have sufficient permissions to explore the
|
||||
* full path of the file.
|
||||
*
|
||||
* ISC_FILE_ABSOLUTE tests for pathnames that start from the root
|
||||
* of a filesystem hierarchy.
|
||||
*
|
||||
* ISC_FILE_CURRENTDIR is an extremely simplistic test. On Unix systems,
|
||||
* it only returns true if the pathname is ".". It will return false
|
||||
* for "subdir/..", for example.
|
||||
*
|
||||
* Unimplemented, perhaps desirable:
|
||||
* ISC_FILE_REGULAR
|
||||
* ISC_FILE_DIRECTORY
|
||||
* ISC_FILE_SYMLINK
|
||||
* ISC_FILE_SPECIAL
|
||||
* ISC_FILE_BLOCK ?
|
||||
* ISC_FILE_CHARACTER ?
|
||||
* ISC_FILE_PIPE ?
|
||||
* ISC_FILE_SOCKET ?
|
||||
* ISC_FILE_READABLE
|
||||
* ISC_FILE_WRITABLE
|
||||
* ISC_FILE_RUNABLE
|
||||
* ISC_FILE_EMPTY
|
||||
*/
|
||||
#define ISC_FILE_EXISTS 0x00000001
|
||||
#define ISC_FILE_ABSOLUTE 0x00000002
|
||||
#define ISC_FILE_CURRENTDIR 0x00000004
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
isc_result_t
|
||||
@@ -199,23 +166,11 @@ isc_file_rename(const char *oldname, const char *newname);
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_file_test(const char *filename, isc_uint32_t what);
|
||||
isc_file_exists(const char *pathname);
|
||||
/*
|
||||
* Test for various file attributes, such as existence or writability.
|
||||
*
|
||||
* Notes:
|
||||
* This is like the Unix shell test(1) command.
|
||||
*
|
||||
* If more than one test is specified in 'what' then ALL
|
||||
* of them must be true for ISC_TRUE to be returned.
|
||||
* To test instead for traits that can be independently true,
|
||||
* use multiple calls to isc_file_test().
|
||||
*
|
||||
* Functionality is being added only as it is needed. See the list
|
||||
* at the start of the file for which tests have been implemented.
|
||||
*
|
||||
* It is intended that this function will supersede both
|
||||
* isc_file_isabsolute() and isc_file_iscurrentdir().
|
||||
* Return ISC_TRUE iff the calling process can tell that the given file exists.
|
||||
* Will not return true if the calling process has insufficient privileges
|
||||
* to search the entire path.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: file.c,v 1.34 2001/05/31 10:53:14 tale Exp $ */
|
||||
/* $Id: file.c,v 1.35 2001/06/08 21:53:49 tale Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -226,33 +226,10 @@ isc_file_rename(const char *oldname, const char *newname) {
|
||||
}
|
||||
|
||||
isc_boolean_t
|
||||
isc_file_test(const char *pathname, isc_uint32_t what) {
|
||||
isc_boolean_t tf = ISC_TRUE;
|
||||
isc_result_t result;
|
||||
isc_file_exists(const char *pathname) {
|
||||
struct stat stats;
|
||||
|
||||
INSIST(what != 0);
|
||||
INSIST((what & ~(ISC_FILE_EXISTS |
|
||||
ISC_FILE_ABSOLUTE |
|
||||
ISC_FILE_CURRENTDIR))
|
||||
== 0);
|
||||
|
||||
if ((what & ISC_FILE_EXISTS) != 0) {
|
||||
/*
|
||||
* When file type tests are implemented, only one
|
||||
* file_stats() should be done.
|
||||
*/
|
||||
result = file_stats(pathname, &stats);
|
||||
tf = ISC_TF(tf && result == ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
if ((what & ISC_FILE_ABSOLUTE) != 0)
|
||||
tf = ISC_TF(tf && pathname[0] == '/');
|
||||
|
||||
if ((what & ISC_FILE_CURRENTDIR) != 0)
|
||||
tf = ISC_TF(tf && pathname[0] == '.' && pathname[1] == '\0');
|
||||
|
||||
return (tf);
|
||||
return (ISC_TF(file_stats(pathname, &stats) == ISC_R_SUCCESS));
|
||||
}
|
||||
|
||||
isc_boolean_t
|
||||
|
||||
Reference in New Issue
Block a user