return f;
}
-#if !defined(TSRM_WIN32)
CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC)
{
cwd_state new_state;
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
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
#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)
#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;
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);
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)
RETURN_FALSE;
}
-#ifndef PHP_WIN32
-
switch (type) {
case FS_IS_W:
RETURN_BOOL (!VCWD_ACCESS(filename, W_OK));
case FS_EXISTS:
RETURN_BOOL (!VCWD_ACCESS(filename, F_OK));
}
-#endif
stat_sb = &BG(sb);
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);