]> granicus.if.org Git - php/commitdiff
Implemented realpath().
authorAndrei Zmievski <andrei@php.net>
Tue, 1 Feb 2000 06:06:03 +0000 (06:06 +0000)
committerAndrei Zmievski <andrei@php.net>
Tue, 1 Feb 2000 06:06:03 +0000 (06:06 +0000)
@ Added realpath() function. (Andrei)

TODO
ext/standard/file.c
ext/standard/file.h

diff --git a/TODO b/TODO
index d460b01ee6a9e3a23a7d458d7177b081303f1855..d110d7d434bd6b8dc97609d63245c179eaf30dbf 100644 (file)
--- a/TODO
+++ b/TODO
@@ -49,7 +49,6 @@ ext/standard
 ------------
     * strpad() (Andrei)
     * stri_replace() (Andrei)
-    * realpath() (Andrei)
     * socket_get_status (Andrei)
     * comparing arrays semantically (like Python) (Andrei)
     * NOT binary safe:
index c5aa4a2201868324aea9e64a2434368b94602bd4..145c92589b06d61b18d3484d128881cd1d96c930 100644 (file)
@@ -86,6 +86,8 @@ extern int fclose();
 #define MAP_FAILED ((void *) -1)
 #endif
 
+#include "php_realpath.h"
+
 /* }}} */
 /* {{{ ZTS-stuff / Globals / Prototypes */
 
@@ -243,6 +245,7 @@ function_entry file_functions[] = {
 #if HAVE_SYS_TIME_H
        PHP_FE(set_socket_timeout,      NULL)
 #endif
+       PHP_FE(realpath,                        NULL)
 #if 0 /* needs to be rethought 991221 thies@digicol.de */
        PHP_FE(fd_set, NULL)
        PHP_FE(fd_isset, NULL)
@@ -1687,6 +1690,26 @@ PHP_FUNCTION(fgetcsv) {
 
 /* }}} */
 
+/* {{{ proto string realpath(string path)
+   Returns the resolved path */
+PHP_FUNCTION(realpath)
+{
+       zval **path;
+       char resolved_path[MAXPATHLEN];
+
+       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &path) == FAILURE) {
+               WRONG_PARAM_COUNT;
+       }
+
+       convert_to_string_ex(path);
+       if (php_realpath((*path)->value.str.val, resolved_path)) {
+               RETURN_STRING(resolved_path, 1);
+       } else {
+               RETURN_FALSE;
+       }
+}
+/* }}} */
+
 #if 0
 
 static fd_set readfd;
index 231935ef56ca7ae613b3686c9ff435f0846db1d8..e0e05cf98fb06fccbaa4bd15acc16ccb4b2c8f20 100644 (file)
@@ -71,6 +71,7 @@ PHP_FUNCTION(flock);
 PHP_FUNCTION(fd_set);
 PHP_FUNCTION(fd_isset);
 PHP_FUNCTION(select);
+PHP_FUNCTION(realpath);
 
 PHPAPI int php_set_sock_blocking(int socketd, int block);
 PHPAPI int php_file_le_fopen(void);