comparison data/fileio/CachedFile.cpp @ 686:b4a8d8221eaf debug-output

Remove most toStdString calls (no longer needed, with debug header)
author Chris Cannam
date Thu, 12 May 2011 17:31:24 +0100
parents e340b2fb9471
children 06f13a3b9e9e
comparison
equal deleted inserted replaced
685:99222d4bfc78 686:b4a8d8221eaf
77 m_ok(false) 77 m_ok(false)
78 { 78 {
79 Profiler p("CachedFile::CachedFile[1]"); 79 Profiler p("CachedFile::CachedFile[1]");
80 80
81 std::cerr << "CachedFile::CachedFile: origin is \"" 81 std::cerr << "CachedFile::CachedFile: origin is \""
82 << origin.toStdString() << "\"" << std::endl; 82 << origin << "\"" << std::endl;
83 check(); 83 check();
84 } 84 }
85 85
86 CachedFile::CachedFile(QUrl url, 86 CachedFile::CachedFile(QUrl url,
87 ProgressReporter *reporter, 87 ProgressReporter *reporter,
92 m_ok(false) 92 m_ok(false)
93 { 93 {
94 Profiler p("CachedFile::CachedFile[2]"); 94 Profiler p("CachedFile::CachedFile[2]");
95 95
96 std::cerr << "CachedFile::CachedFile: url is \"" 96 std::cerr << "CachedFile::CachedFile: url is \""
97 << url.toString().toStdString() << "\"" << std::endl; 97 << url.toString() << "\"" << std::endl;
98 check(); 98 check();
99 } 99 }
100 100
101 CachedFile::~CachedFile() 101 CachedFile::~CachedFile()
102 { 102 {
138 138
139 QDateTime lastRetrieval = getLastRetrieval(); 139 QDateTime lastRetrieval = getLastRetrieval();
140 140
141 if (lastRetrieval.isValid()) { 141 if (lastRetrieval.isValid()) {
142 std::cerr << "CachedFile::check: Valid last retrieval at " 142 std::cerr << "CachedFile::check: Valid last retrieval at "
143 << lastRetrieval.toString().toStdString() << std::endl; 143 << lastRetrieval.toString() << std::endl;
144 // this will not be the case if the file is missing, after 144 // this will not be the case if the file is missing, after
145 // updateLastRetrieval(false) was called above 145 // updateLastRetrieval(false) was called above
146 m_ok = true; 146 m_ok = true;
147 if (lastRetrieval.addDays(2) < QDateTime::currentDateTime()) { //!!! 147 if (lastRetrieval.addDays(2) < QDateTime::currentDateTime()) { //!!!
148 std::cerr << "CachedFile::check: Out of date; trying to retrieve again" << std::endl; 148 std::cerr << "CachedFile::check: Out of date; trying to retrieve again" << std::endl;
203 } 203 }
204 204
205 QString tempName = fs.getLocalFilename(); 205 QString tempName = fs.getLocalFilename();
206 QFile tempFile(tempName); 206 QFile tempFile(tempName);
207 if (!tempFile.exists()) { 207 if (!tempFile.exists()) {
208 std::cerr << "CachedFile::retrieve: ERROR: FileSource reported success, but local temporary file \"" << tempName.toStdString() << "\" does not exist" << std::endl; 208 std::cerr << "CachedFile::retrieve: ERROR: FileSource reported success, but local temporary file \"" << tempName << "\" does not exist" << std::endl;
209 return false; 209 return false;
210 } 210 }
211 211
212 QFile previous(m_localFilename); 212 QFile previous(m_localFilename);
213 if (previous.exists()) { 213 if (previous.exists()) {
214 if (!previous.remove()) { 214 if (!previous.remove()) {
215 std::cerr << "CachedFile::retrieve: ERROR: Failed to remove previous copy of cached file at \"" << m_localFilename.toStdString() << "\"" << std::endl; 215 std::cerr << "CachedFile::retrieve: ERROR: Failed to remove previous copy of cached file at \"" << m_localFilename << "\"" << std::endl;
216 return false; 216 return false;
217 } 217 }
218 } 218 }
219 219
220 //!!! This is not ideal, could leave us with nothing (old file 220 //!!! This is not ideal, could leave us with nothing (old file
221 //!!! removed, new file not able to be copied in because e.g. no 221 //!!! removed, new file not able to be copied in because e.g. no
222 //!!! disk space left) 222 //!!! disk space left)
223 223
224 if (!tempFile.copy(m_localFilename)) { 224 if (!tempFile.copy(m_localFilename)) {
225 std::cerr << "CachedFile::retrieve: ERROR: Failed to copy newly retrieved file from \"" << tempName.toStdString() << "\" to \"" << m_localFilename.toStdString() << "\"" << std::endl; 225 std::cerr << "CachedFile::retrieve: ERROR: Failed to copy newly retrieved file from \"" << tempName << "\" to \"" << m_localFilename << "\"" << std::endl;
226 return false; 226 return false;
227 } 227 }
228 228
229 std::cerr << "CachedFile::retrieve: Successfully copied newly retrieved file \"" << tempName.toStdString() << "\" to its home at \"" << m_localFilename.toStdString() << "\"" << std::endl; 229 std::cerr << "CachedFile::retrieve: Successfully copied newly retrieved file \"" << tempName << "\" to its home at \"" << m_localFilename << "\"" << std::endl;
230 230
231 return true; 231 return true;
232 } 232 }
233 233
234 QDateTime 234 QDateTime