|
|
|
@ -282,29 +282,6 @@ CWD_API char *virtual_getcwd(char *buf, size_t size TSRMLS_DC) |
|
|
|
return buf; |
|
|
|
} |
|
|
|
|
|
|
|
CWD_API char *virtual_link(char *buf, size_t size TSRMLS_DC) |
|
|
|
{ |
|
|
|
char *p; |
|
|
|
char tmp_path[MAXPATHLEN * 2]; |
|
|
|
char resolved_path[MAXPATHLEN]; |
|
|
|
|
|
|
|
if (IS_ABSOLUTE_PATH(buf, size)) { |
|
|
|
p = resolved_path; |
|
|
|
memcpy(p, buf, size); |
|
|
|
p[size] = '\0'; |
|
|
|
} else { |
|
|
|
virtual_getcwd(tmp_path, MAXPATHLEN TSRMLS_CC); |
|
|
|
p = tmp_path + strlen(tmp_path); |
|
|
|
*p++ = '/'; |
|
|
|
memcpy(p, buf, size); |
|
|
|
*(p + size) = '\0'; |
|
|
|
|
|
|
|
p = tmp_path; |
|
|
|
} |
|
|
|
|
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
/* 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) |
|
|
|
@ -709,24 +686,30 @@ CWD_API int virtual_stat(const char *path, struct stat_libc *buf TSRMLS_DC) |
|
|
|
#if !defined(TSRM_WIN32) && !defined(NETWARE) |
|
|
|
CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC) |
|
|
|
{ |
|
|
|
cwd_state new_state; |
|
|
|
int retval; |
|
|
|
char *p; |
|
|
|
|
|
|
|
p = virtual_link((char *)path, strlen(path) TSRMLS_CC); |
|
|
|
retval = lstat(p, buf); |
|
|
|
CWD_STATE_COPY(&new_state, &CWDG(cwd)); |
|
|
|
virtual_file_ex(&new_state, path, NULL); |
|
|
|
|
|
|
|
retval = lstat(new_state.cwd, buf); |
|
|
|
|
|
|
|
CWD_STATE_FREE(&new_state); |
|
|
|
return retval; |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
CWD_API int virtual_unlink(const char *path TSRMLS_DC) |
|
|
|
{ |
|
|
|
cwd_state new_state; |
|
|
|
int retval; |
|
|
|
char *resolved_path; |
|
|
|
|
|
|
|
resolved_path = virtual_link((char *)path, strlen(path) TSRMLS_CC); |
|
|
|
retval = unlink(resolved_path); |
|
|
|
CWD_STATE_COPY(&new_state, &CWDG(cwd)); |
|
|
|
virtual_file_ex(&new_state, path, NULL); |
|
|
|
|
|
|
|
retval = unlink(new_state.cwd); |
|
|
|
|
|
|
|
CWD_STATE_FREE(&new_state); |
|
|
|
return retval; |
|
|
|
} |
|
|
|
|
|
|
|
|