comparison data/fileio/FileSource.cpp @ 661:a4faa1840384

* If a FileSource URL won't convert at all in strict mode, try again in tolerant mode (necessary for e.g. filenames with square brackets in them)
author Chris Cannam
date Tue, 19 Oct 2010 21:47:55 +0100
parents 3a61a4df6d53
children 948271d124ac
comparison
equal deleted inserted replaced
660:5db8181ea521 661:a4faa1840384
81 m_done(false), 81 m_done(false),
82 m_leaveLocalFile(false), 82 m_leaveLocalFile(false),
83 m_reporter(reporter), 83 m_reporter(reporter),
84 m_refCounted(false) 84 m_refCounted(false)
85 { 85 {
86 #ifdef DEBUG_FILE_SOURCE 86 if (m_url.toString() == "") {
87 std::cerr << "FileSource::FileSource(" << fileOrUrl.toStdString() << ")" << std::endl; 87 m_url = QUrl(fileOrUrl, QUrl::TolerantMode);
88 }
89
90 #ifdef DEBUG_FILE_SOURCE
91 std::cerr << "FileSource::FileSource(" << fileOrUrl.toStdString() << "): url <" << m_url.toString().toStdString() << ">" << std::endl;
88 incCount(m_url.toString()); 92 incCount(m_url.toString());
89 #endif 93 #endif
90 94
91 if (!canHandleScheme(m_url)) { 95 if (!canHandleScheme(m_url)) {
92 std::cerr << "FileSource::FileSource: ERROR: Unsupported scheme in URL \"" << m_url.toString().toStdString() << "\"" << std::endl; 96 std::cerr << "FileSource::FileSource: ERROR: Unsupported scheme in URL \"" << m_url.toString().toStdString() << "\"" << std::endl;
264 } 268 }
265 m_localFilename = QFileInfo(m_localFilename).absoluteFilePath(); 269 m_localFilename = QFileInfo(m_localFilename).absoluteFilePath();
266 270
267 #ifdef DEBUG_FILE_SOURCE 271 #ifdef DEBUG_FILE_SOURCE
268 std::cerr << "FileSource::init: URL translates to local filename \"" 272 std::cerr << "FileSource::init: URL translates to local filename \""
269 << m_localFilename.toStdString() << "\"" << std::endl; 273 << m_localFilename.toStdString() << "\" (with literal=" << literal << ")" << std::endl;
270 #endif 274 #endif
271 m_ok = true; 275 m_ok = true;
272 m_lastStatus = 200; 276 m_lastStatus = 200;
273 277
274 if (!QFileInfo(m_localFilename).exists()) { 278 if (!QFileInfo(m_localFilename).exists()) {