diff options
author | Stanislav Malyshev <stas@php.net> | 2000-06-04 08:29:11 +0000 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2000-06-04 08:29:11 +0000 |
commit | 5af7dff7581ac7314c57ed525d590f9709a5d432 (patch) | |
tree | c8eb9f80133958d39341f6c90a4351bb3527d832 | |
parent | 375474ce8632b113d025861308057c44573b2900 (diff) | |
download | php-git-5af7dff7581ac7314c57ed525d590f9709a5d432.tar.gz |
add opendir to VIRTUAL_DIR
-rw-r--r-- | ext/standard/dir.c | 2 | ||||
-rw-r--r-- | main/php.h | 2 | ||||
-rw-r--r-- | main/php_virtual_cwd.c | 15 | ||||
-rw-r--r-- | main/php_virtual_cwd.h | 8 |
4 files changed, 26 insertions, 1 deletions
diff --git a/ext/standard/dir.c b/ext/standard/dir.c index 93aef51e7b..a79dac8c78 100644 --- a/ext/standard/dir.c +++ b/ext/standard/dir.c @@ -141,7 +141,7 @@ static void _php_do_opendir(INTERNAL_FUNCTION_PARAMETERS, int createobject) dirp = emalloc(sizeof(php_dir)); - dirp->dir = opendir((*arg)->value.str.val); + dirp->dir = V_OPENDIR((*arg)->value.str.val); if (! dirp->dir) { efree(dirp); diff --git a/main/php.h b/main/php.h index 20d0f1cbde..59fdf6a370 100644 --- a/main/php.h +++ b/main/php.h @@ -306,6 +306,7 @@ PHPAPI int cfg_get_string(char *varname, char **result); #define V_UNLINK(path) virtual_unlink(path) #define V_MKDIR(pathname, mode) virtual_mkdir(pathname, mode) #define V_RMDIR(pathname) virtual_rmdir(pathname) +#define V_OPENDIR(pathname) virtual_opendir(pathname) #else #define V_GETCWD(buff, size) getcwd(buff,size) #define V_FOPEN(path, mode) fopen(path, mode) @@ -319,6 +320,7 @@ PHPAPI int cfg_get_string(char *varname, char **result); #define V_UNLINK(path) unlink(path) #define V_MKDIR(pathname, mode) mkdir(pathname, mode) #define V_RMDIR(pathname) rmdir(pathname) +#define V_OPENDIR(pathname) opendir(pathname) #endif #include "zend_constants.h" diff --git a/main/php_virtual_cwd.c b/main/php_virtual_cwd.c index 412929db15..03ba8f4b21 100644 --- a/main/php_virtual_cwd.c +++ b/main/php_virtual_cwd.c @@ -533,6 +533,21 @@ CWD_API int virtual_rmdir(const char *pathname) return retval; } +CWD_API DIR *virtual_opendir(const char *pathname) +{ + cwd_state new_state; + DIR *retval; + CWDLS_FETCH(); + + CWD_STATE_COPY(&new_state, &CWDG(cwd)); + virtual_file_ex(&new_state, pathname, NULL); + + retval = opendir(new_state.cwd); + + CWD_STATE_FREE(&new_state); + return retval; +} + #if 0 main(void) diff --git a/main/php_virtual_cwd.h b/main/php_virtual_cwd.h index dfd810a118..9d6150a07c 100644 --- a/main/php_virtual_cwd.h +++ b/main/php_virtual_cwd.h @@ -11,6 +11,13 @@ #include <unistd.h> #endif +#ifdef ZEND_WIN32 +#include "win32/readdir.h" +#else +#ifdef HAVE_DIRENT_H +#include <dirent.h> +#endif +#endif #ifdef PHP_EXPORTS #define CWD_EXPORTS @@ -51,6 +58,7 @@ CWD_API int virtual_lstat(const char *path, struct stat *buf); CWD_API int virtual_unlink(const char *path); CWD_API int virtual_mkdir(const char *pathname, mode_t mode); CWD_API int virtual_rmdir(const char *pathname); +CWD_API DIR *virtual_opendir(const char *pathname); CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path); |