1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

is_executable() now available on win32

stats can now get information provided by access()
This commit is contained in:
Shane Caraveo
2003-02-09 03:49:43 +00:00
parent 086cb15f43
commit 5048f8c60e
7 changed files with 34 additions and 11 deletions

View 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

View 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)

View 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;

View 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);

View 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)

View 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);

View 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);