summaryrefslogtreecommitdiff
path: root/TSRM
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 /TSRM
parent086cb15f433893e3a8a0f7ddf42561a45da339ce (diff)
downloadphp-git-5048f8c60ea1d2f4c8e945bc151e77620bb1e44b.tar.gz
is_executable() now available on win32
stats can now get information provided by access()
Diffstat (limited to 'TSRM')
-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
4 files changed, 34 insertions, 4 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);