#define PUTS_H(str) php_header_write((str), strlen((str)))
#define PUTC_H(c) (php_header_write(&(c), 1), (c))
-/* #define VIRTUAL_DIR */
+#define VIRTUAL_DIR
#include "php_virtual_cwd.h"
/* Virtual current directory support */
#define V_LSTAT(path, buff) virtual_lstat(path, buff)
#endif
#define V_UNLINK(path) virtual_unlink(path)
+#define V_MKDIR(pathname, mode) virtual_mkdir(pathname, mode)
+#define V_RMDIR(pathname) virtual_rmdir(pathname)
#else
#define V_GETCWD(buff, size) getcwd(buff,size)
#define V_FOPEN(path, mode) fopen(path, mode)
#define V_STAT(path, buff) stat(path, buff)
#define V_LSTAT(path, buff) lstat(path, buff)
#define V_UNLINK(path) unlink(path)
+#define V_MKDIR(pathname, mode) mkdir(pathname, mode)
+#define V_RMDIR(pathname) rmdir(pathname)
#endif
#include "zend_constants.h"
CWDLS_FETCH();
CWD_STATE_COPY(&new_state, &CWDG(cwd));
-
retval = virtual_file_ex(&new_state, path, php_is_file_ok);
+
*filepath = new_state.cwd;
+
return retval;
}
CWDLS_FETCH();
CWD_STATE_COPY(&new_state, &CWDG(cwd));
-
virtual_file_ex(&new_state, path, NULL);
f = fopen(new_state.cwd, mode);
+
CWD_STATE_FREE(&new_state);
return f;
}
CWDLS_FETCH();
CWD_STATE_COPY(&new_state, &CWDG(cwd));
-
virtual_file_ex(&new_state, path, NULL);
if (flags & O_CREAT) {
CWDLS_FETCH();
CWD_STATE_COPY(&new_state, &CWDG(cwd));
-
virtual_file_ex(&new_state, path, NULL);
f = open(new_state.cwd, O_CREAT | O_TRUNC, mode);
CWDLS_FETCH();
CWD_STATE_COPY(&new_state, &CWDG(cwd));
-
virtual_file_ex(&new_state, path, NULL);
retval = stat(new_state.cwd, buf);
+
CWD_STATE_FREE(&new_state);
return retval;
}
CWDLS_FETCH();
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;
}
CWDLS_FETCH();
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;
+}
+
+CWD_API int virtual_mkdir(const char *pathname, mode_t mode)
+{
+ cwd_state new_state;
+ int retval;
+ CWDLS_FETCH();
+
+ CWD_STATE_COPY(&new_state, &CWDG(cwd));
+ virtual_file_ex(&new_state, pathname, NULL);
+
+ retval = mkdir(new_state.cwd, mode);
+
+ CWD_STATE_FREE(&new_state);
+ return retval;
+}
+
+CWD_API int virtual_rmdir(const char *pathname)
+{
+ cwd_state new_state;
+ int retval;
+ CWDLS_FETCH();
+
+ CWD_STATE_COPY(&new_state, &CWDG(cwd));
+ virtual_file_ex(&new_state, pathname, NULL);
+
+ retval = rmdir(new_state.cwd);
+
CWD_STATE_FREE(&new_state);
return retval;
}