Commit ba35e992 authored by Andreas Gustafsson's avatar Andreas Gustafsson

added isc_file_ischdiridempotent()

parent cda18e78
......@@ -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);
/*
......
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment