From: Thies C. Arntzen Date: Wed, 20 Oct 1999 16:17:30 +0000 (+0000) Subject: (PHP getcwd()) added, needs to porting to Win32 X-Git-Tag: php-4.0b3_RC2~114 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=33ebd5238741a224d67e75f6f7e47ba9c2341ffd;p=php (PHP getcwd()) added, needs to porting to Win32 @- added getcwd() function. (Thies) # as we do have chdir() now we have getcwd() - i think we *should* restore the # working directory in RSHUTDOWN! --- diff --git a/ext/standard/config.h.stub b/ext/standard/config.h.stub index 69ee82467f..6e29dd4810 100644 --- a/ext/standard/config.h.stub +++ b/ext/standard/config.h.stub @@ -12,3 +12,6 @@ /* Define if you have libdl (used for dynamic linking) */ #define HAVE_LIBDL 0 + +#undef HAVE_GETWD +#undef HAVE_GETCWD diff --git a/ext/standard/config.m4 b/ext/standard/config.m4 index 64887d8d1a..9949ffbd94 100644 --- a/ext/standard/config.m4 +++ b/ext/standard/config.m4 @@ -118,6 +118,8 @@ AC_CHECK_LIB(crypt, crypt, [ AC_ADD_LIBRARY(crypt) AC_DEFINE(HAVE_LIBCRYPT) ], []) +AC_CHECK_FUNCS(getcwd) +AC_CHECK_FUNCS(getwd) divert(3) diff --git a/ext/standard/dir.c b/ext/standard/dir.c index cdec22e3f6..3345d255c6 100644 --- a/ext/standard/dir.c +++ b/ext/standard/dir.c @@ -86,6 +86,7 @@ static zend_function_entry php_dir_functions[] = { PHP_FE(opendir, NULL) PHP_FE(closedir, NULL) PHP_FE(chdir, NULL) + PHP_FE(getcwd, NULL) PHP_FE(rewinddir, NULL) PHP_FE(readdir, NULL) PHP_FALIAS(dir, getdir, NULL) @@ -210,9 +211,10 @@ PHP_FUNCTION(closedir) php3_list_delete(dirp->id); } + /* }}} */ /* {{{ proto int chdir(string directory) -Change the current directory */ + Change the current directory */ PHP_FUNCTION(chdir) { @@ -233,6 +235,35 @@ PHP_FUNCTION(chdir) RETURN_TRUE; } + +/* }}} */ +/* {{{ proto string getcwd() + Gets the current directory */ + +PHP_FUNCTION(getcwd) +{ + char path[MAXPATHLEN]; + char *ret; + + if (ARG_COUNT(ht) != 0) { + WRONG_PARAM_COUNT; + } + +#if HAVE_GETCWD + ret = getcwd(path,MAXPATHLEN-1); +#elif HAVE_GETWD + ret = getwd(path); +#elif +#warning no proper getcwd support for your site +#endif + + if (ret) { + RETURN_STRING(path,1); + } else { + RETURN_FALSE; + } +} + /* }}} */ /* {{{ proto void rewinddir([int dir_handle]) Rewind dir_handle back to the start */ diff --git a/ext/standard/php3_dir.h b/ext/standard/php3_dir.h index 8b5e2af026..86ccda21c2 100644 --- a/ext/standard/php3_dir.h +++ b/ext/standard/php3_dir.h @@ -29,6 +29,7 @@ extern PHP_MINIT_FUNCTION(dir); PHP_FUNCTION(opendir); PHP_FUNCTION(closedir); PHP_FUNCTION(chdir); +PHP_FUNCTION(getcwd); PHP_FUNCTION(rewinddir); PHP_FUNCTION(readdir); PHP_FUNCTION(getdir);