comparison base/ResourceFinder.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 27cdabba2d3e
children 06f13a3b9e9e
comparison
equal deleted inserted replaced
685:99222d4bfc78 686:b4a8d8221eaf
150 for (QStringList::const_iterator i = prefixes.begin(); 150 for (QStringList::const_iterator i = prefixes.begin();
151 i != prefixes.end(); ++i) { 151 i != prefixes.end(); ++i) {
152 152
153 QString prefix = *i; 153 QString prefix = *i;
154 154
155 std::cerr << "ResourceFinder::getResourcePath: Looking up file \"" << fileName.toStdString() << "\" for category \"" << resourceCat.toStdString() << "\" in prefix \"" << prefix.toStdString() << "\"" << std::endl; 155 std::cerr << "ResourceFinder::getResourcePath: Looking up file \"" << fileName << "\" for category \"" << resourceCat << "\" in prefix \"" << prefix << "\"" << std::endl;
156 156
157 QString path = 157 QString path =
158 QString("%1%2/%3").arg(prefix).arg(resourceCat).arg(fileName); 158 QString("%1%2/%3").arg(prefix).arg(resourceCat).arg(fileName);
159 if (QFileInfo(path).exists() && QFileInfo(path).isReadable()) { 159 if (QFileInfo(path).exists() && QFileInfo(path).isReadable()) {
160 std::cerr << "Found it!" << std::endl; 160 std::cerr << "Found it!" << std::endl;
209 if (resourceCat != "") resourceCat = "/" + resourceCat; 209 if (resourceCat != "") resourceCat = "/" + resourceCat;
210 210
211 QDir userDir(user); 211 QDir userDir(user);
212 if (!userDir.exists()) { 212 if (!userDir.exists()) {
213 if (!userDir.mkpath(user)) { 213 if (!userDir.mkpath(user)) {
214 std::cerr << "ResourceFinder::getResourceSaveDir: ERROR: Failed to create user resource path \"" << user.toStdString() << "\"" << std::endl; 214 std::cerr << "ResourceFinder::getResourceSaveDir: ERROR: Failed to create user resource path \"" << user << "\"" << std::endl;
215 return ""; 215 return "";
216 } 216 }
217 } 217 }
218 218
219 if (resourceCat != "") { 219 if (resourceCat != "") {
220 QString save = QString("%1%2").arg(user).arg(resourceCat); 220 QString save = QString("%1%2").arg(user).arg(resourceCat);
221 QDir saveDir(save); 221 QDir saveDir(save);
222 if (!saveDir.exists()) { 222 if (!saveDir.exists()) {
223 if (!userDir.mkpath(save)) { 223 if (!userDir.mkpath(save)) {
224 std::cerr << "ResourceFinder::getResourceSaveDir: ERROR: Failed to create user resource path \"" << save.toStdString() << "\"" << std::endl; 224 std::cerr << "ResourceFinder::getResourceSaveDir: ERROR: Failed to create user resource path \"" << save << "\"" << std::endl;
225 return ""; 225 return "";
226 } 226 }
227 } 227 }
228 return save; 228 return save;
229 } else { 229 } else {
276 if (!path.startsWith(':')) return true; 276 if (!path.startsWith(':')) return true;
277 277
278 // This is the lowest-priority alternative path for this 278 // This is the lowest-priority alternative path for this
279 // resource, so we know that there must be no installed copy. 279 // resource, so we know that there must be no installed copy.
280 // Install one to the user location. 280 // Install one to the user location.
281 std::cerr << "ResourceFinder::unbundleResource: File " << fileName.toStdString() << " is bundled, un-bundling it" << std::endl; 281 std::cerr << "ResourceFinder::unbundleResource: File " << fileName << " is bundled, un-bundling it" << std::endl;
282 QString target = getResourceSavePath(resourceCat, fileName); 282 QString target = getResourceSavePath(resourceCat, fileName);
283 QFile file(path); 283 QFile file(path);
284 if (!file.copy(target)) { 284 if (!file.copy(target)) {
285 std::cerr << "ResourceFinder::unbundleResource: ERROR: Failed to un-bundle resource file \"" << fileName.toStdString() << "\" to user location \"" << target.toStdString() << "\"" << std::endl; 285 std::cerr << "ResourceFinder::unbundleResource: ERROR: Failed to un-bundle resource file \"" << fileName << "\" to user location \"" << target << "\"" << std::endl;
286 return false; 286 return false;
287 } 287 }
288 288
289 // Now since the file is in the user's editable space, the user should get 289 // Now since the file is in the user's editable space, the user should get
290 // to edit it. The chords.xml file I unbundled came out 444 instead of 644 290 // to edit it. The chords.xml file I unbundled came out 444 instead of 644