35#ifdef HAVE_SYS_PARAM_H
36# include <sys/param.h>
42# define MAXPATHLEN PHP_WIN32_IOUTIL_MAXPATHLEN
44# define MAXPATHLEN PATH_MAX
45# elif defined(MAX_PATH)
46# define MAXPATHLEN MAX_PATH
48# define MAXPATHLEN 256
62#if defined(__osf__) || defined(_AIX)
73typedef unsigned short mode_t;
75#define DEFAULT_SLASH '\\'
76#define DEFAULT_DIR_SEPARATOR ';'
77#define IS_SLASH(c) ((c) == '/' || (c) == '\\')
79#define IS_SLASH_P(c) (*(c) == '/' || \
80 (*(c) == '\\' && !IsDBCSLeadByte(*(c-1))))
81#define IS_SLASH_P_EX(c, first_byte) (*(c) == '/' || \
82 (*(c) == '\\' && ((first_byte) || !IsDBCSLeadByte(*(c-1)))))
86#define COPY_WHEN_ABSOLUTE(path) 2
87#define IS_UNC_PATH(path, len) \
88 (len >= 2 && IS_SLASH(path[0]) && IS_SLASH(path[1]))
89#define IS_ABSOLUTE_PATH(path, len) \
90 (len >= 2 && (isalpha(path[0]) && path[1] == ':' || IS_SLASH(path[0]) && IS_SLASH(path[1])))
107#define DEFAULT_SLASH '/'
110#define DEFAULT_DIR_SEPARATOR ';'
112#define DEFAULT_DIR_SEPARATOR ':'
115#define IS_SLASH(c) ((c) == '/')
117#define IS_SLASH_P(c) (*(c) == '/')
118#define IS_SLASH_P_EX(c, first_byte) IS_SLASH_P(c)
123#ifndef COPY_WHEN_ABSOLUTE
124#define COPY_WHEN_ABSOLUTE(path) 0
127#ifndef IS_ABSOLUTE_PATH
128#define IS_ABSOLUTE_PATH(path, len) \
138# define CWD_API __declspec(dllexport)
140# define CWD_API __declspec(dllimport)
142#elif defined(__GNUC__) && __GNUC__ >= 4
143# define CWD_API __attribute__ ((visibility("default")))
149# define php_sys_stat_ex php_win32_ioutil_stat_ex
150# define php_sys_stat php_win32_ioutil_stat
151# define php_sys_lstat php_win32_ioutil_lstat
152# define php_sys_fstat php_win32_ioutil_fstat
153# define php_sys_readlink php_win32_ioutil_readlink
154# define php_sys_symlink php_win32_ioutil_symlink
155# define php_sys_link php_win32_ioutil_link
157# define php_sys_stat stat
158# define php_sys_lstat lstat
159# define php_sys_fstat fstat
161# define php_sys_readlink(link, target, target_len) readlink(link, target, target_len)
162# define php_sys_symlink symlink
163# define php_sys_link link
199CWD_API int virtual_utime(
const char *filename,
struct utimbuf *
buf);
202#if !defined(ZEND_WIN32)
211#define CWD_FILEPATH 1
212#define CWD_REALPATH 2
218#define REALPATH_CACHE_TTL (2*60)
219#define REALPATH_CACHE_SIZE 0
247extern ts_rsrc_id cwd_globals_id;
248extern size_t cwd_globals_offset;
249# define CWDG(v) ZEND_TSRMG_FAST(cwd_globals_offset, virtual_cwd_globals *, v)
252# define CWDG(v) (cwd_globals.v)
273#define VCWD_GETCWD(buff, size) virtual_getcwd(buff, size)
274#define VCWD_FOPEN(path, mode) virtual_fopen(path, mode)
276#define VCWD_OPEN(path, flags) virtual_open(path, flags)
277#define VCWD_OPEN_MODE(path, flags, mode) virtual_open(path, flags, mode)
278#define VCWD_CREAT(path, mode) virtual_creat(path, mode)
279#define VCWD_CHDIR(path) virtual_chdir(path)
280#define VCWD_CHDIR_FILE(path) virtual_chdir_file(path, (int (*)(const char *)) virtual_chdir)
281#define VCWD_GETWD(buf)
282#define VCWD_REALPATH(path, real_path) virtual_realpath(path, real_path)
283#define VCWD_RENAME(oldname, newname) virtual_rename(oldname, newname)
284#define VCWD_STAT(path, buff) virtual_stat(path, buff)
285# define VCWD_LSTAT(path, buff) virtual_lstat(path, buff)
286#define VCWD_UNLINK(path) virtual_unlink(path)
287#define VCWD_MKDIR(pathname, mode) virtual_mkdir(pathname, mode)
288#define VCWD_RMDIR(pathname) virtual_rmdir(pathname)
289#define VCWD_OPENDIR(pathname) virtual_opendir(pathname)
290#define VCWD_POPEN(command, type) virtual_popen(command, type)
291#define VCWD_ACCESS(pathname, mode) virtual_access(pathname, mode)
293#define VCWD_UTIME(path, time) virtual_utime(path, time)
295#define VCWD_CHMOD(path, mode) virtual_chmod(path, mode)
296#if !defined(ZEND_WIN32)
297#define VCWD_CHOWN(path, owner, group) virtual_chown(path, owner, group, 0)
299#define VCWD_LCHOWN(path, owner, group) virtual_chown(path, owner, group, 1)
305#define VCWD_CREAT(path, mode) creat(path, mode)
308#if defined(ZEND_WIN32)
309#define VCWD_FOPEN(path, mode) php_win32_ioutil_fopen(path, mode)
310#define VCWD_OPEN(path, flags) php_win32_ioutil_open(path, flags)
311#define VCWD_OPEN_MODE(path, flags, mode) php_win32_ioutil_open(path, flags, mode)
312# define VCWD_RENAME(oldname, newname) php_win32_ioutil_rename(oldname, newname)
313#define VCWD_MKDIR(pathname, mode) php_win32_ioutil_mkdir(pathname, mode)
314#define VCWD_RMDIR(pathname) php_win32_ioutil_rmdir(pathname)
315#define VCWD_UNLINK(path) php_win32_ioutil_unlink(path)
316#define VCWD_CHDIR(path) php_win32_ioutil_chdir(path)
317#define VCWD_ACCESS(pathname, mode) tsrm_win32_access(pathname, mode)
318#define VCWD_GETCWD(buff, size) php_win32_ioutil_getcwd(buff, size)
319#define VCWD_CHMOD(path, mode) php_win32_ioutil_chmod(path, mode)
321#define VCWD_FOPEN(path, mode) fopen(path, mode)
322#define VCWD_OPEN(path, flags) open(path, flags)
323#define VCWD_OPEN_MODE(path, flags, mode) open(path, flags, mode)
324# define VCWD_RENAME(oldname, newname) rename(oldname, newname)
325#define VCWD_MKDIR(pathname, mode) mkdir(pathname, mode)
326#define VCWD_RMDIR(pathname) rmdir(pathname)
327#define VCWD_UNLINK(path) unlink(path)
328#define VCWD_CHDIR(path) chdir(path)
329#define VCWD_ACCESS(pathname, mode) access(pathname, mode)
330#define VCWD_GETCWD(buff, size) getcwd(buff, size)
331#define VCWD_CHMOD(path, mode) chmod(path, mode)
334#define VCWD_CHDIR_FILE(path) virtual_chdir_file(path, chdir)
335#define VCWD_GETWD(buf) getwd(buf)
336#define VCWD_STAT(path, buff) php_sys_stat(path, buff)
337#define VCWD_LSTAT(path, buff) lstat(path, buff)
338#define VCWD_OPENDIR(pathname) opendir(pathname)
339#define VCWD_POPEN(command, type) popen(command, type)
341#define VCWD_REALPATH(path, real_path) tsrm_realpath(path, real_path)
345# define VCWD_UTIME(path, time) win32_utime(path, time)
347# define VCWD_UTIME(path, time) utime(path, time)
351#if !defined(ZEND_WIN32)
352#define VCWD_CHOWN(path, owner, group) chown(path, owner, group)
354#define VCWD_LCHOWN(path, owner, group) lchown(path, owner, group)
362#define _S_IFDIR S_IFDIR
366#define _S_IFREG S_IFREG
370#define _IFLNK 0120000
371#define S_IFLNK _IFLNK
375#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
379#define S_ISREG(mode) (((mode)&S_IFMT) == S_IFREG)
383#define S_ISLNK(mode) (((mode)&S_IFMT) == S_IFLNK)
387#define S_IXROOT ( S_IXUSR | S_IXGRP | S_IXOTH )
392#define _IFIFO 0010000
393#define S_IFIFO _IFIFO
397#define _IFBLK 0060000
398#define S_IFBLK _IFBLK
is_readable(string $filename)
is_writable(string $filename)
link(string $target, string $link)
zend_ffi_ctype_name_buf buf
struct _realpath_cache_bucket * next
realpath_cache_bucket * realpath_cache[1024]
zend_long realpath_cache_size
zend_long realpath_cache_size_limit
zend_long realpath_cache_ttl
ZEND_RESULT_CODE zend_result
void virtual_cwd_main_cwd_init(uint8_t reinit)
virtual_cwd_globals cwd_globals
CWD_API void virtual_cwd_shutdown(void)
struct _realpath_cache_bucket realpath_cache_bucket
CWD_API char * virtual_getcwd_ex(size_t *length)
CWD_API int virtual_chmod(const char *filename, mode_t mode)
CWD_API int virtual_stat(const char *path, zend_stat_t *buf)
CWD_API void realpath_cache_del(const char *path, size_t path_len)
CWD_API void virtual_cwd_activate(void)
CWD_API realpath_cache_bucket * realpath_cache_lookup(const char *path, size_t path_len, time_t t)
int(* verify_path_func)(const cwd_state *)
CWD_API int virtual_chdir_file(const char *path, int(*p_chdir)(const char *path))
CWD_API int virtual_unlink(const char *path)
CWD_API int virtual_filepath(const char *path, char **filepath)
CWD_API int virtual_open(const char *path, int flags,...)
CWD_API zend_long realpath_cache_max_buckets(void)
CWD_API int virtual_access(const char *pathname, int mode)
CWD_API zend_result virtual_chdir(const char *path)
CWD_API FILE * virtual_fopen(const char *path, const char *mode)
CWD_API void virtual_cwd_deactivate(void)
CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_func verify_path)
CWD_API int virtual_mkdir(const char *pathname, mode_t mode)
CWD_API int virtual_rmdir(const char *pathname)
CWD_API int virtual_rename(const char *oldname, const char *newname)
CWD_API char * tsrm_realpath(const char *path, char *real_path)
CWD_API int virtual_creat(const char *path, mode_t mode)
CWD_API char * virtual_realpath(const char *path, char *real_path)
CWD_API int virtual_lstat(const char *path, zend_stat_t *buf)
CWD_API realpath_cache_bucket ** realpath_cache_get_buckets(void)
CWD_API void virtual_cwd_startup(void)
CWD_API char * virtual_getcwd(char *buf, size_t size)
CWD_API FILE * virtual_popen(const char *command, const char *type)
CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group, int link)
CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path, int use_realpath)
struct _cwd_state cwd_state
struct _virtual_cwd_globals virtual_cwd_globals
CWD_API void realpath_cache_clean(void)
CWD_API DIR * virtual_opendir(const char *pathname)
CWD_API zend_long realpath_cache_size(void)