comparison data/fileio/FileSource.cpp @ 355:d02f71281639

* Fix #1841095 tapping time instant gives wrong time in aligned track * Fix #1815654 source tidying: Labeller * Fix (I hope) #1849999 Time value graphs one instant out
author Chris Cannam
date Thu, 13 Dec 2007 17:14:33 +0000
parents 4175a4930186
children b92513201610
comparison
equal deleted inserted replaced
354:048b21bc9891 355:d02f71281639
25 #include <QProgressDialog> 25 #include <QProgressDialog>
26 #include <QHttpResponseHeader> 26 #include <QHttpResponseHeader>
27 27
28 #include <iostream> 28 #include <iostream>
29 29
30 //#define DEBUG_FILE_SOURCE 1 30 #define DEBUG_FILE_SOURCE 1
31 31
32 int 32 int
33 FileSource::m_count = 0; 33 FileSource::m_count = 0;
34 34
35 QMutex 35 QMutex
198 198
199 void 199 void
200 FileSource::init(bool showProgress) 200 FileSource::init(bool showProgress)
201 { 201 {
202 if (!isRemote()) { 202 if (!isRemote()) {
203 #ifdef DEBUG_FILE_SOURCE
204 std::cerr << "FileSource::init: Not a remote URL" << std::endl;
205 #endif
206 bool literal = false;
203 m_localFilename = m_url.toLocalFile(); 207 m_localFilename = m_url.toLocalFile();
204 if (m_localFilename == "") { 208 if (m_localFilename == "") {
205 // QUrl may have mishandled the scheme (e.g. in a DOS path) 209 // QUrl may have mishandled the scheme (e.g. in a DOS path)
206 m_localFilename = m_url.toString(); 210 m_localFilename = m_url.toString();
207 } 211 literal = true;
212 }
213 #ifdef DEBUG_FILE_SOURCE
214 std::cerr << "FileSource::init: URL translates to local filename \""
215 << m_localFilename.toStdString() << "\"" << std::endl;
216 #endif
208 m_ok = true; 217 m_ok = true;
218 m_lastStatus = 200;
219
209 if (!QFileInfo(m_localFilename).exists()) { 220 if (!QFileInfo(m_localFilename).exists()) {
210 m_lastStatus = 404; 221 if (literal) {
211 } else { 222 m_lastStatus = 404;
212 m_lastStatus = 200; 223 } else {
213 } 224 // Again, QUrl may have been mistreating us --
225 // e.g. dropping a part that looks like query data
226 m_localFilename = m_url.toString();
227 literal = true;
228 if (!QFileInfo(m_localFilename).exists()) {
229 m_lastStatus = 404;
230 }
231 }
232 }
233
214 m_done = true; 234 m_done = true;
215 return; 235 return;
216 } 236 }
217 237
218 if (createCacheFile()) { 238 if (createCacheFile()) {