summaryrefslogtreecommitdiff
path: root/main/php_virtual_cwd.c
diff options
context:
space:
mode:
authorSascha Schumann <sas@php.net>2000-08-20 12:49:56 +0000
committerSascha Schumann <sas@php.net>2000-08-20 12:49:56 +0000
commitc86ec8b1a95e9c4716bffff816427419f295183c (patch)
tree48b4a567071ff1a70cc840c614b251b02afad4f0 /main/php_virtual_cwd.c
parentf75db1e3cbbdf5b5e7101dc393627f5241b41490 (diff)
downloadphp-git-c86ec8b1a95e9c4716bffff816427419f295183c.tar.gz
Add virtual_real_chdir_file. Silly name for a useful function.
Diffstat (limited to 'main/php_virtual_cwd.c')
-rw-r--r--main/php_virtual_cwd.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/main/php_virtual_cwd.c b/main/php_virtual_cwd.c
index 4d09ce6750..5b2838385c 100644
--- a/main/php_virtual_cwd.c
+++ b/main/php_virtual_cwd.c
@@ -745,6 +745,26 @@ CWD_API FILE *virtual_popen(const char *command, const char *type)
#endif
+/* taken from Apache 1.3 */
+
+CWD_API void virtual_real_chdir_file(const char *file)
+{
+ const char *x;
+ char buf[4096];
+
+ x = strrchr(file, '/');
+ if (x == NULL) {
+ chdir(file);
+ }
+ else if (x - file < sizeof(buf) - 1) {
+ memcpy(buf, file, x - file);
+ buf[x - file] = '\0';
+ chdir(buf);
+ }
+ /* XXX: well, this is a silly function, no method of reporting an
+ * error... ah well. */
+}
+
#if 0
main(void)