Skip to content

Commit db3f744

Browse files
author
Sascha Schumann
committed
Add VCWD_ACCESS
1 parent 4f05796 commit db3f744

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

TSRM/tsrm_virtual_cwd.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,24 @@ CWD_API FILE *virtual_fopen(const char *path, const char *mode TSRMLS_DC)
540540
return f;
541541
}
542542

543+
#if !defined(TSRM_WIN32)
544+
CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC)
545+
{
546+
cwd_state new_state;
547+
int ret;
548+
549+
CWD_STATE_COPY(&new_state, &CWDG(cwd));
550+
virtual_file_ex(&new_state, pathname, NULL);
551+
552+
ret = access(new_state.cwd, mode);
553+
554+
CWD_STATE_FREE(&new_state);
555+
556+
return ret;
557+
}
558+
#endif
559+
560+
543561
#if HAVE_UTIME
544562
CWD_API int virtual_utime(const char *filename, struct utimbuf *buf TSRMLS_DC)
545563
{

TSRM/tsrm_virtual_cwd.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ CWD_API int virtual_mkdir(const char *pathname, mode_t mode TSRMLS_DC);
146146
CWD_API int virtual_rmdir(const char *pathname TSRMLS_DC);
147147
CWD_API DIR *virtual_opendir(const char *pathname TSRMLS_DC);
148148
CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC);
149+
150+
#if !defined(TSRM_WIN32)
151+
CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC);
152+
#endif
153+
149154
#if HAVE_UTIME
150155
CWD_API int virtual_utime(const char *filename, struct utimbuf *buf TSRMLS_DC);
151156
#endif
@@ -195,6 +200,7 @@ typedef struct _virtual_cwd_globals {
195200
#define VCWD_RMDIR(pathname) virtual_rmdir(pathname TSRMLS_CC)
196201
#define VCWD_OPENDIR(pathname) virtual_opendir(pathname TSRMLS_CC)
197202
#define VCWD_POPEN(command, type) virtual_popen(command, type TSRMLS_CC)
203+
#define VCWD_ACCESS(pathname, mode) virtual_access(pathname, mode TSRMLS_CC)
198204
#if HAVE_UTIME
199205
#define VCWD_UTIME(path, time) virtual_utime(path, time TSRMLS_CC)
200206
#endif
@@ -221,6 +227,7 @@ typedef struct _virtual_cwd_globals {
221227
#define VCWD_RMDIR(pathname) rmdir(pathname)
222228
#define VCWD_OPENDIR(pathname) opendir(pathname)
223229
#define VCWD_POPEN(command, type) popen(command, type)
230+
#define VCWD_ACCESS(pathname, mode) access(pathname, mode)
224231

225232
#if !defined(TSRM_WIN32) && !defined(NETWARE)
226233
#define VCWD_REALPATH(path, real_path) realpath(path, real_path)

0 commit comments

Comments
 (0)