/* Resolve path relatively to state and put the real path into state */
/* returns 0 for ok, 1 for error */
-CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path)
+CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path, int use_realpath)
{
int path_length = strlen(path);
char *ptr, *path_copy;
#if !defined(TSRM_WIN32) && !defined(NETWARE)
if (IS_ABSOLUTE_PATH(path, path_length)) {
- if (realpath(path, resolved_path)) {
+ if (use_realpath && realpath(path, resolved_path)) {
path = resolved_path;
path_length = strlen(path);
}
memcpy(ptr, path, path_length);
ptr += path_length;
*ptr = '\0';
- if (realpath(tmp, resolved_path)) {
+ if (use_realpath && realpath(tmp, resolved_path)) {
path = resolved_path;
path_length = strlen(path);
}
CWD_API int virtual_chdir(const char *path TSRMLS_DC)
{
- return virtual_file_ex(&CWDG(cwd), path, php_is_dir_ok)?-1:0;
+ return virtual_file_ex(&CWDG(cwd), path, php_is_dir_ok, 1)?-1:0;
}
CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path TSRMLS_DC) TSRMLS_DC)
int retval;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- retval = virtual_file_ex(&new_state, path, NULL);
+ retval = virtual_file_ex(&new_state, path, NULL, 1);
if (!retval) {
int len = new_state.cwd_length>MAXPATHLEN-1?MAXPATHLEN-1:new_state.cwd_length;
int retval;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- retval = virtual_file_ex(&new_state, path, verify_path);
+ retval = virtual_file_ex(&new_state, path, verify_path, 1);
*filepath = new_state.cwd;
}
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- virtual_file_ex(&new_state, path, NULL);
+ virtual_file_ex(&new_state, path, NULL, 1);
f = fopen(new_state.cwd, mode);
int ret;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- virtual_file_ex(&new_state, pathname, NULL);
+ virtual_file_ex(&new_state, pathname, NULL, 1);
ret = access(new_state.cwd, mode);
int ret;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- virtual_file_ex(&new_state, filename, NULL);
+ virtual_file_ex(&new_state, filename, NULL, 0);
ret = utime(new_state.cwd, buf);
int ret;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- virtual_file_ex(&new_state, filename, NULL);
+ virtual_file_ex(&new_state, filename, NULL, 1);
ret = chmod(new_state.cwd, mode);
int ret;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- virtual_file_ex(&new_state, filename, NULL);
+ virtual_file_ex(&new_state, filename, NULL, 0);
ret = chown(new_state.cwd, owner, group);
int f;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- virtual_file_ex(&new_state, path, NULL);
+ virtual_file_ex(&new_state, path, NULL, 1);
if (flags & O_CREAT) {
mode_t mode;
int f;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- virtual_file_ex(&new_state, path, NULL);
+ virtual_file_ex(&new_state, path, NULL, 1);
f = creat(new_state.cwd, mode);
int retval;
CWD_STATE_COPY(&old_state, &CWDG(cwd));
- virtual_file_ex(&old_state, oldname, NULL);
+ virtual_file_ex(&old_state, oldname, NULL, 0);
oldname = old_state.cwd;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- virtual_file_ex(&new_state, newname, NULL);
+ virtual_file_ex(&new_state, newname, NULL, 0);
newname = new_state.cwd;
retval = rename(oldname, newname);
int retval;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- virtual_file_ex(&new_state, path, NULL);
+ virtual_file_ex(&new_state, path, NULL, 1);
retval = stat(new_state.cwd, buf);
int retval;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- virtual_file_ex(&new_state, path, NULL);
+ virtual_file_ex(&new_state, path, NULL, 1);
retval = stat(new_state.cwd, (struct stat*)buf);
int retval;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- virtual_file_ex(&new_state, path, NULL);
+ virtual_file_ex(&new_state, path, NULL, 0);
retval = lstat(new_state.cwd, buf);
int retval;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- virtual_file_ex(&new_state, path, NULL);
+ virtual_file_ex(&new_state, path, NULL, 0);
retval = unlink(new_state.cwd);
int retval;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- virtual_file_ex(&new_state, pathname, NULL);
+ virtual_file_ex(&new_state, pathname, NULL, 1);
#ifdef TSRM_WIN32
retval = mkdir(new_state.cwd);
int retval;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- virtual_file_ex(&new_state, pathname, NULL);
+ virtual_file_ex(&new_state, pathname, NULL, 0);
retval = rmdir(new_state.cwd);
DIR *retval;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- virtual_file_ex(&new_state, pathname, NULL);
+ virtual_file_ex(&new_state, pathname, NULL, 1);
retval = opendir(new_state.cwd);