]> granicus.if.org Git - php/commitdiff
(PHP getcwd()) added, needs to porting to Win32
authorThies C. Arntzen <thies@php.net>
Wed, 20 Oct 1999 16:17:30 +0000 (16:17 +0000)
committerThies C. Arntzen <thies@php.net>
Wed, 20 Oct 1999 16:17:30 +0000 (16:17 +0000)
@- added getcwd() function. (Thies)
# as we do have chdir() now we have getcwd() - i think we *should* restore the
# working directory in RSHUTDOWN!

ext/standard/config.h.stub
ext/standard/config.m4
ext/standard/dir.c
ext/standard/php3_dir.h

index 69ee82467fa8e8d4177f22941e79e4d4664b3403..6e29dd4810ee6aa00539541a878e0c7d4d6990d6 100644 (file)
@@ -12,3 +12,6 @@
 
 /* Define if you have libdl (used for dynamic linking) */
 #define HAVE_LIBDL 0
+
+#undef HAVE_GETWD
+#undef HAVE_GETCWD
index 64887d8d1a1b0708335b878b7056f6e525af5cb7..9949ffbd943741717ef56c4fc850261316ccf5a1 100644 (file)
@@ -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)
 
index cdec22e3f6879565cf0a7a008e92c195118ed00a..3345d255c6ae350ba9cd4de3f2005034ea889863 100644 (file)
@@ -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 */
index 8b5e2af026137a4efe360eeb3ccab2e06b5c5b6e..86ccda21c219c34ef8c4c48132e16fc38eb43256 100644 (file)
@@ -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);