]> granicus.if.org Git - php/commitdiff
A simpler patch to add file uri support
authorShane Caraveo <shane@php.net>
Sun, 19 Oct 2003 20:59:12 +0000 (20:59 +0000)
committerShane Caraveo <shane@php.net>
Sun, 19 Oct 2003 20:59:12 +0000 (20:59 +0000)
main/streams/plain_wrapper.c
main/streams/streams.c

index 1f060ec6663302df65c96760ab7024c486d7e580..5286f4fcb256e913d3c007f43b7d329d2b7cbe30 100644 (file)
@@ -882,6 +882,16 @@ static php_stream *php_plain_files_dir_opener(php_stream_wrapper *wrapper, char
 static php_stream *php_plain_files_stream_opener(php_stream_wrapper *wrapper, char *path, char *mode,
                int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC)
 {
+       char *filename = path;
+       if (!strncasecmp(filename, "file:", sizeof("file:")-1)) {
+               filename += 6;
+               while (*(++filename)=='/');
+#ifdef PHP_WIN32
+               if (*(filename + 1) != ':')
+#endif
+                       filename--;
+       }
+
        if ((options & USE_PATH) && PG(include_path) != NULL) {
                return php_stream_fopen_with_path_rel(path, mode, PG(include_path), opened_path, options);
        }
index 49a34cdcdbb243cea7490bc24fdbf7f74cb604eb..d7579378c1b9b48cfe02d60c98ff61e95d1bd8de 100755 (executable)
@@ -1415,14 +1415,20 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, char
        }
        /* TODO: curl based streams probably support file:// properly */
        if (!protocol || !strncasecmp(protocol, "file", n))     {
-               if (protocol && path[n+1] == '/' && path[n+2] == '/')   {
+               if (protocol && path[n+1] == '/' && path[n+2] == '/' && path[n+3] != '/')       {
                        if (options & REPORT_ERRORS) {
                                php_error_docref(NULL TSRMLS_CC, E_WARNING, "remote host file access not supported, %s", path);
                        }
                        return NULL;
                }
                if (protocol && path_for_open) {
+                       /* skip past protocol and :/, but handle windows correctly */
                        *path_for_open = (char*)path + n + 1;
+                       while (*(++*path_for_open)=='/');
+#ifdef PHP_WIN32
+                       if (*(*path_for_open + 1) != ':')
+#endif
+                               *path_for_open--;
                }
                
                /* fall back on regular file access */