]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
893. [func] Removed isc_file_test() and added isc_file_exists()
authorDavid Lawrence <source@isc.org>
Fri, 8 Jun 2001 21:53:49 +0000 (21:53 +0000)
committerDavid Lawrence <source@isc.org>
Fri, 8 Jun 2001 21:53:49 +0000 (21:53 +0000)
for the basic functionality that was being added
with isc_file_test().

CHANGES
bin/rndc/rndc.c
lib/isc/include/isc/file.h
lib/isc/unix/file.c

diff --git a/CHANGES b/CHANGES
index 1647eafead4692a6d25da07d0f8244d9919dfb5c..0b7aec4c979819aba425b8f34de56a8154d9af0d 100644 (file)
--- a/CHANGES
+++ b/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
index 8c0fde3e6e19e22558523d416fbd5f0d53128ceb..5de6b9de1f94039329aad43ca7bbebaf4599929f 100644 (file)
@@ -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);
        }
index 9541d3e0ec929a331af5a40b4c5fe0814b897f84..5b89efce75575835d6e0b80841c48f95f31e62f9 100644 (file)
@@ -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
 #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
index 2c98d54d6d8bf37fca067826789d2795d1dad6f0..b2fb04f3bbf73bb8a091c417ae14590b793604fd 100644 (file)
@@ -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