]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
added isc_file_ischdiridempotent()
authorAndreas Gustafsson <source@isc.org>
Mon, 16 Jul 2001 18:33:02 +0000 (18:33 +0000)
committerAndreas Gustafsson <source@isc.org>
Mon, 16 Jul 2001 18:33:02 +0000 (18:33 +0000)
lib/isc/include/isc/file.h
lib/isc/unix/file.c
lib/isc/win32/file.c

index 3870ca238f87a72c783e59d5ebbe3bc9788e223b..649fef457458eaf9b353d0fd0ce6fa739a7b3418 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: file.h,v 1.23 2001/07/16 17:22:16 gson Exp $ */
+/* $Id: file.h,v 1.24 2001/07/16 18:33:00 gson Exp $ */
 
 #ifndef ISC_FILE_H
 #define ISC_FILE_H 1
@@ -185,6 +185,13 @@ isc_file_iscurrentdir(const char *filename);
  * Return ISC_TRUE iff the given file name is the current directory (".").
  */
 
+isc_boolean_t
+isc_file_ischdiridempotent(const char *filename);
+/*
+ * Return ISC_TRUE if calling chdir(filename) multiple times will give
+ * the same result as calling it once.
+ */
+
 const char *
 isc_file_basename(const char *filename);
 /*
index e599986e10535058c12b4fa4a961c9641dd9cb7a..da002828129a06f22518a07dcb84fd4996d4337c 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: file.c,v 1.37 2001/07/16 17:26:44 gson Exp $ */
+/* $Id: file.c,v 1.38 2001/07/16 18:33:01 gson Exp $ */
 
 #include <config.h>
 
@@ -261,6 +261,16 @@ isc_file_iscurrentdir(const char *filename) {
        return (ISC_TF(filename[0] == '.' && filename[1] == '\0'));
 }
 
+isc_boolean_t
+isc_file_ischdiridempotent(const char *filename) {
+       REQUIRE(filename != NULL);
+       if (isc_file_isabsolute(filename))
+               return (ISC_TRUE);
+       if (isc_file_iscurrentdir(filename))
+               return (ISC_TRUE);
+       return (ISC_FALSE);
+}
+
 const char *
 isc_file_basename(const char *filename) {
        char *s;
index d1ef5d9a8fca21dc7f098a8b02e8ebf51c490273..d6335e297f27b671ccf0b60145b30e186d9d627f 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: file.c,v 1.18 2001/07/16 17:22:17 gson Exp $ */
+/* $Id: file.c,v 1.19 2001/07/16 18:33:02 gson Exp $ */
 
 #include <config.h>
 
@@ -402,6 +402,21 @@ isc_file_iscurrentdir(const char *filename) {
        return (ISC_TF(filename[0] == '.' && filename[1] == '\0'));
 }
 
+isc_boolean_t
+isc_file_ischdiridempotent(const char *filename) {
+       REQUIRE(filename != NULL);
+
+       if (isc_file_isabsolute(filename))
+               return (ISC_TRUE);
+       if (filename[0] == '\\')
+               return (ISC_TRUE);
+       if (filename[0] == '/')
+               return (ISC_TRUE);
+       if (isc_file_iscurrentdir(filename))
+               return (ISC_TRUE);
+       return (ISC_FALSE);
+}
+
 const char *
 isc_file_basename(const char *filename) {
        char *s;