2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

895. [func] New function, isc_dir_current(), akin to POSIX's

getcwd().
This commit is contained in:
David Lawrence
2001-06-08 23:50:32 +00:00
parent 0e873a1202
commit 04260c5c48
3 changed files with 43 additions and 2 deletions

View File

@@ -1,4 +1,7 @@
895. [func] New function, isc_dir_current(), akin to POSIX's
getcwd().
894. [bug] When using the DNSSEC tools, a message intended to warn
when the keyboard was being used because of the lack
of a suitable random device was not being printed.

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dir.c,v 1.17 2001/06/04 19:33:32 tale Exp $ */
/* $Id: dir.c,v 1.18 2001/06/08 23:50:31 tale Exp $ */
/* Principal Authors: DCL */
@@ -155,6 +155,34 @@ isc_dir_chroot(const char *dirname) {
return (ISC_R_SUCCESS);
}
isc_result_t
isc_dir_current(char *dirname, size_t length, isc_boolean_t end_sep) {
char *cwd;
isc_result_t result = ISC_R_SUCCESS;
/*
* XXXDCL Could automatically allocate memory if dirname == NULL.
*/
REQUIRE(dirname != NULL);
REQUIRE(length > 0);
cwd = getcwd(dirname, length);
if (cwd == NULL) {
if (errno == ERANGE)
result = ISC_R_NOSPACE;
else
result = isc__errno2result(errno);
} else if (end_sep) {
if (strlen(dirname) + 1 == length)
result = ISC_R_NOSPACE;
else if (dirname[1] != '\0')
strcat(dirname, "/");
}
return (result);
}
isc_result_t
isc_dir_createunique(char *templet) {
isc_result_t result;

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dir.h,v 1.13 2001/01/29 03:17:45 marka Exp $ */
/* $Id: dir.h,v 1.14 2001/06/08 23:50:32 tale Exp $ */
/* Principal Authors: DCL */
@@ -76,6 +76,16 @@ isc_dir_chdir(const char *dirname);
isc_result_t
isc_dir_chroot(const char *dirname);
isc_result_t
isc_dir_current(char *dirname, size_t length, isc_boolean_t end_sep);
/*
* Put the absolute name of the current directory into 'dirname', which is a
* buffer of at least 'length' characters. If 'end_sep' is true, end the
* string with the appropriate path separator, such that the final product
* could be concatenated with a relative pathname to make a valid pathname
* string.
*/
isc_result_t
isc_dir_createunique(char *templet);
/*