Mercurial > hg > svcore
comparison data/fileio/CachedFile.cpp @ 520:e340b2fb9471
* Make FileSource able to indicate its preferred content type (e.g.
application/rdf+xml in preference to text/html for rdf content)
* Temp directory on Windows -- make $HOME expand to homedrive+homepath
instead of user profile location (which may be networked)
author | Chris Cannam |
---|---|
date | Thu, 11 Dec 2008 15:18:10 +0000 |
parents | a82645e788fc |
children | b4a8d8221eaf |
comparison
equal
deleted
inserted
replaced
519:21f86744d38e | 520:e340b2fb9471 |
---|---|
66 } | 66 } |
67 | 67 |
68 return fi.filePath(); | 68 return fi.filePath(); |
69 } | 69 } |
70 | 70 |
71 CachedFile::CachedFile(QString origin, ProgressReporter *reporter) : | 71 CachedFile::CachedFile(QString origin, |
72 ProgressReporter *reporter, | |
73 QString preferredContentType) : | |
72 m_origin(origin), | 74 m_origin(origin), |
75 m_preferredContentType(preferredContentType), | |
73 m_reporter(reporter), | 76 m_reporter(reporter), |
74 m_ok(false) | 77 m_ok(false) |
75 { | 78 { |
76 Profiler p("CachedFile::CachedFile[1]"); | 79 Profiler p("CachedFile::CachedFile[1]"); |
77 | 80 |
78 std::cerr << "CachedFile::CachedFile: origin is \"" | 81 std::cerr << "CachedFile::CachedFile: origin is \"" |
79 << origin.toStdString() << "\"" << std::endl; | 82 << origin.toStdString() << "\"" << std::endl; |
80 check(); | 83 check(); |
81 } | 84 } |
82 | 85 |
83 CachedFile::CachedFile(QUrl url, ProgressReporter *reporter) : | 86 CachedFile::CachedFile(QUrl url, |
87 ProgressReporter *reporter, | |
88 QString preferredContentType) : | |
84 m_origin(url.toString()), | 89 m_origin(url.toString()), |
90 m_preferredContentType(preferredContentType), | |
85 m_reporter(reporter), | 91 m_reporter(reporter), |
86 m_ok(false) | 92 m_ok(false) |
87 { | 93 { |
88 Profiler p("CachedFile::CachedFile[2]"); | 94 Profiler p("CachedFile::CachedFile[2]"); |
89 | 95 |
180 //!!! then "atomically" moving it to its proper place (I'm not | 186 //!!! then "atomically" moving it to its proper place (I'm not |
181 //!!! sure we can do an atomic move to replace an existing file | 187 //!!! sure we can do an atomic move to replace an existing file |
182 //!!! using Qt classes, but a plain delete then copy is probably | 188 //!!! using Qt classes, but a plain delete then copy is probably |
183 //!!! good enough) | 189 //!!! good enough) |
184 | 190 |
185 FileSource fs(m_origin, m_reporter); | 191 FileSource fs(m_origin, m_reporter, m_preferredContentType); |
186 | 192 |
187 if (!fs.isOK() || !fs.isAvailable()) { | 193 if (!fs.isOK() || !fs.isAvailable()) { |
188 std::cerr << "CachedFile::retrieve: ERROR: FileSource reported unavailable or failure" << std::endl; | 194 std::cerr << "CachedFile::retrieve: ERROR: FileSource reported unavailable or failure" << std::endl; |
189 return false; | 195 return false; |
190 } | 196 } |