changeset 342:4175a4930186

* Fixes for handling of DOS paths (C:\blah) -- not an unknown URL scheme!
author Chris Cannam
date Mon, 26 Nov 2007 15:05:51 +0000
parents db8fcd280234
children 46519c04321b
files data/fileio/FileSource.cpp
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/data/fileio/FileSource.cpp	Mon Nov 26 13:33:14 2007 +0000
+++ b/data/fileio/FileSource.cpp	Mon Nov 26 15:05:51 2007 +0000
@@ -201,6 +201,10 @@
 {
     if (!isRemote()) {
         m_localFilename = m_url.toLocalFile();
+        if (m_localFilename == "") {
+            // QUrl may have mishandled the scheme (e.g. in a DOS path)
+            m_localFilename = m_url.toString();
+        }
         m_ok = true;
         if (!QFileInfo(m_localFilename).exists()) {
             m_lastStatus = 404;
@@ -403,16 +407,19 @@
 bool
 FileSource::isRemote(QString fileOrUrl)
 {
+    // Note that a "scheme" with length 1 is probably a DOS drive letter
     QString scheme = QUrl(fileOrUrl).scheme().toLower();
-    return (scheme == "http" || scheme == "ftp");
+    if (scheme == "" || scheme == "file" || scheme.length() == 1) return false;
+    return true;
 }
 
 bool
 FileSource::canHandleScheme(QUrl url)
 {
+    // Note that a "scheme" with length 1 is probably a DOS drive letter
     QString scheme = url.scheme().toLower();
     return (scheme == "http" || scheme == "ftp" ||
-            scheme == "file" || scheme == "");
+            scheme == "file" || scheme == "" || scheme.length() == 1);
 }
 
 bool