comparison data/fileio/FileSource.cpp @ 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 5cd7f6d10d47
children d02f71281639 94fc0591ea43
comparison
equal deleted inserted replaced
341:db8fcd280234 342:4175a4930186
199 void 199 void
200 FileSource::init(bool showProgress) 200 FileSource::init(bool showProgress)
201 { 201 {
202 if (!isRemote()) { 202 if (!isRemote()) {
203 m_localFilename = m_url.toLocalFile(); 203 m_localFilename = m_url.toLocalFile();
204 if (m_localFilename == "") {
205 // QUrl may have mishandled the scheme (e.g. in a DOS path)
206 m_localFilename = m_url.toString();
207 }
204 m_ok = true; 208 m_ok = true;
205 if (!QFileInfo(m_localFilename).exists()) { 209 if (!QFileInfo(m_localFilename).exists()) {
206 m_lastStatus = 404; 210 m_lastStatus = 404;
207 } else { 211 } else {
208 m_lastStatus = 200; 212 m_lastStatus = 200;
401 } 405 }
402 406
403 bool 407 bool
404 FileSource::isRemote(QString fileOrUrl) 408 FileSource::isRemote(QString fileOrUrl)
405 { 409 {
410 // Note that a "scheme" with length 1 is probably a DOS drive letter
406 QString scheme = QUrl(fileOrUrl).scheme().toLower(); 411 QString scheme = QUrl(fileOrUrl).scheme().toLower();
407 return (scheme == "http" || scheme == "ftp"); 412 if (scheme == "" || scheme == "file" || scheme.length() == 1) return false;
413 return true;
408 } 414 }
409 415
410 bool 416 bool
411 FileSource::canHandleScheme(QUrl url) 417 FileSource::canHandleScheme(QUrl url)
412 { 418 {
419 // Note that a "scheme" with length 1 is probably a DOS drive letter
413 QString scheme = url.scheme().toLower(); 420 QString scheme = url.scheme().toLower();
414 return (scheme == "http" || scheme == "ftp" || 421 return (scheme == "http" || scheme == "ftp" ||
415 scheme == "file" || scheme == ""); 422 scheme == "file" || scheme == "" || scheme.length() == 1);
416 } 423 }
417 424
418 bool 425 bool
419 FileSource::isAvailable() 426 FileSource::isAvailable()
420 { 427 {