]> granicus.if.org Git - php/commitdiff
is_executable() now available on win32
authorShane Caraveo <shane@php.net>
Sun, 9 Feb 2003 03:49:43 +0000 (03:49 +0000)
committerShane Caraveo <shane@php.net>
Sun, 9 Feb 2003 03:49:43 +0000 (03:49 +0000)
stats can now get information provided by access()

TSRM/tsrm_virtual_cwd.c
TSRM/tsrm_virtual_cwd.h
TSRM/tsrm_win32.c
TSRM/tsrm_win32.h
ext/standard/basic_functions.c
ext/standard/filestat.c
ext/standard/php_filestat.h

index c14080ef059e58acfdc581d74b73adb2fc346261..082cdf96a5e841651088df26525114dfaf40e500 100644 (file)
@@ -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
index d77e8f8166a0bb2d1ad7aef89937ecded2aff963..d001a20e4d62a43530b64fc8f9b5ae2dd1019566 100644 (file)
@@ -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)
index 46365b5fc19417bfe4d248ae579f74bc4b7b676e..dccf86e851aa394ad9682fdc6a1eb73cbbc66949 100644 (file)
@@ -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;
index 1401a86b3a2035997bfc71248ee47d6b43115cd0..a027b8a4a94f70ea2ac0e9a4c14680ce96e8ab4c 100644 (file)
@@ -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);
index 3809dc145bbd68b61888dd268b684da926223ae3..4481a2f42f34c777e84141d9f9ded75eeac64a96 100644 (file)
@@ -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)
index 349e4222d8811fcf5ac46483bbb57da84378f3bd..f7ab3af0d3161e7fc7f5bb9b98c133496411e66d 100644 (file)
@@ -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);
 
index 77601486943bbbdbe5da55ddf1f4accf35a53760..39d08ecfc7b820d353f3901d296cef4ef0722974 100644 (file)
@@ -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);