summaryrefslogtreecommitdiff
path: root/ext/standard/dir.c
diff options
context:
space:
mode:
authorThies C. Arntzen <thies@php.net>1999-10-20 16:17:30 +0000
committerThies C. Arntzen <thies@php.net>1999-10-20 16:17:30 +0000
commit33ebd5238741a224d67e75f6f7e47ba9c2341ffd (patch)
treea7d5341a0dee50fb17ec68227bdb1f268d993ea6 /ext/standard/dir.c
parentdf6d06def40c1e3fb890825a6c695171832a8c93 (diff)
downloadphp-git-33ebd5238741a224d67e75f6f7e47ba9c2341ffd.tar.gz
(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!
Diffstat (limited to 'ext/standard/dir.c')
-rw-r--r--ext/standard/dir.c33
1 files changed, 32 insertions, 1 deletions
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 */