summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShane Caraveo <shane@php.net>2003-02-09 03:49:43 +0000
committerShane Caraveo <shane@php.net>2003-02-09 03:49:43 +0000
commit5048f8c60ea1d2f4c8e945bc151e77620bb1e44b (patch)
tree23572a56f02cabaa49e8c220f9e4e3538eef7f15
parent086cb15f433893e3a8a0f7ddf42561a45da339ce (diff)
downloadphp-git-5048f8c60ea1d2f4c8e945bc151e77620bb1e44b.tar.gz
is_executable() now available on win32
stats can now get information provided by access()
-rw-r--r--TSRM/tsrm_virtual_cwd.c6
-rw-r--r--TSRM/tsrm_virtual_cwd.h20
-rw-r--r--TSRM/tsrm_win32.c11
-rw-r--r--TSRM/tsrm_win32.h1
-rw-r--r--ext/standard/basic_functions.c2
-rw-r--r--ext/standard/filestat.c3
-rw-r--r--ext/standard/php_filestat.h2
7 files changed, 34 insertions, 11 deletions
diff --git a/TSRM/tsrm_virtual_cwd.c b/TSRM/tsrm_virtual_cwd.c
index c14080ef05..082cdf96a5 100644
--- a/TSRM/tsrm_virtual_cwd.c
+++ b/TSRM/tsrm_virtual_cwd.c
@@ -530,7 +530,6 @@ CWD_API FILE *virtual_fopen(const char *path, const char *mode TSRMLS_DC)
return f;
}
-#if !defined(TSRM_WIN32)
CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC)
{
cwd_state new_state;
@@ -539,13 +538,16 @@ CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC)
CWD_STATE_COPY(&new_state, &CWDG(cwd));
virtual_file_ex(&new_state, pathname, NULL, 1);
+#if defined(TSRM_WIN32)
+ ret = tsrm_win32_access(new_state.cwd, mode);
+#else
ret = access(new_state.cwd, mode);
+#endif
CWD_STATE_FREE(&new_state);
return ret;
}
-#endif
#if HAVE_UTIME
diff --git a/TSRM/tsrm_virtual_cwd.h b/TSRM/tsrm_virtual_cwd.h
index d77e8f8166..d001a20e4d 100644
--- a/TSRM/tsrm_virtual_cwd.h
+++ b/TSRM/tsrm_virtual_cwd.h
@@ -150,9 +150,21 @@ CWD_API int virtual_mkdir(const char *pathname, mode_t mode TSRMLS_DC);
CWD_API int virtual_rmdir(const char *pathname TSRMLS_DC);
CWD_API DIR *virtual_opendir(const char *pathname TSRMLS_DC);
CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC);
-
-#if !defined(TSRM_WIN32)
CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC);
+#if defined(TSRM_WIN32)
+/* these are not defined in win32 headers */
+#ifndef W_OK
+#define W_OK 0x02
+#endif
+#ifndef R_OK
+#define R_OK 0x04
+#endif
+#ifndef X_OK
+#define X_OK 0x01
+#endif
+#ifndef F_OK
+#define F_OK 0x00
+#endif
#endif
#if HAVE_UTIME
@@ -231,7 +243,11 @@ typedef struct _virtual_cwd_globals {
#define VCWD_RMDIR(pathname) rmdir(pathname)
#define VCWD_OPENDIR(pathname) opendir(pathname)
#define VCWD_POPEN(command, type) popen(command, type)
+#if defined(TSRM_WIN32)
+#define VCWD_ACCESS(pathname, mode) tsrm_win32_access(pathname, mode)
+#else
#define VCWD_ACCESS(pathname, mode) access(pathname, mode)
+#endif
#ifdef HAVE_REALPATH
#define VCWD_REALPATH(path, real_path) realpath(path, real_path)
diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c
index 46365b5fc1..dccf86e851 100644
--- a/TSRM/tsrm_win32.c
+++ b/TSRM/tsrm_win32.c
@@ -81,6 +81,17 @@ TSRM_API void tsrm_win32_shutdown(void)
#endif
}
+TSRM_API int tsrm_win32_access(const char *pathname, int mode)
+{
+ SHFILEINFO sfi;
+ if (mode == 1 /*X_OK*/)
+ return access(pathname, 0)==0 &&
+ SHGetFileInfo(pathname,0,&sfi,sizeof(SHFILEINFO),SHGFI_EXETYPE)!=0?0:-1;
+ else
+ return access(pathname, mode);
+}
+
+
static process_pair *process_get(FILE *stream TSRMLS_DC)
{
process_pair *ptr;
diff --git a/TSRM/tsrm_win32.h b/TSRM/tsrm_win32.h
index 1401a86b3a..a027b8a4a9 100644
--- a/TSRM/tsrm_win32.h
+++ b/TSRM/tsrm_win32.h
@@ -95,6 +95,7 @@ TSRM_API void tsrm_win32_shutdown(void);
TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, char *env);
TSRM_API FILE *popen(const char *command, const char *type);
TSRM_API int pclose(FILE *stream);
+TSRM_API int tsrm_win32_access(const char *pathname, int mode);
TSRM_API int shmget(int key, int size, int flags);
TSRM_API void *shmat(int key, const void *shmaddr, int flags);
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 3809dc145b..4481a2f42f 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -747,9 +747,7 @@ function_entry basic_functions[] = {
PHP_FE(is_writable, NULL)
PHP_FALIAS(is_writeable, is_writable, NULL)
PHP_FE(is_readable, NULL)
-#ifndef PHP_WIN32
PHP_FE(is_executable, NULL)
-#endif
PHP_FE(is_file, NULL)
PHP_FE(is_dir, NULL)
PHP_FE(is_link, NULL)
diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c
index 349e4222d8..f7ab3af0d3 100644
--- a/ext/standard/filestat.c
+++ b/ext/standard/filestat.c
@@ -572,8 +572,6 @@ static void php_stat(const char *filename, php_stat_len filename_length, int typ
RETURN_FALSE;
}
-#ifndef PHP_WIN32
-
switch (type) {
case FS_IS_W:
RETURN_BOOL (!VCWD_ACCESS(filename, W_OK));
@@ -584,7 +582,6 @@ static void php_stat(const char *filename, php_stat_len filename_length, int typ
case FS_EXISTS:
RETURN_BOOL (!VCWD_ACCESS(filename, F_OK));
}
-#endif
stat_sb = &BG(sb);
diff --git a/ext/standard/php_filestat.h b/ext/standard/php_filestat.h
index 7760148694..39d08ecfc7 100644
--- a/ext/standard/php_filestat.h
+++ b/ext/standard/php_filestat.h
@@ -36,9 +36,7 @@ PHP_FUNCTION(filesize);
PHP_FUNCTION(filetype);
PHP_FUNCTION(is_writable);
PHP_FUNCTION(is_readable);
-#ifndef PHP_WIN32
PHP_FUNCTION(is_executable);
-#endif
PHP_FUNCTION(is_file);
PHP_FUNCTION(is_dir);
PHP_FUNCTION(is_link);