Mercurial > hg > svcore
comparison data/fileio/FileFinder.cpp @ 347:7a5a9b6d50c7 1.2-stable
* merge fixes from trunk
author | Chris Cannam |
---|---|
date | Thu, 29 Nov 2007 17:16:02 +0000 |
parents | c324d410b096 |
children |
comparison
equal
deleted
inserted
replaced
345:700cd3350391 | 347:7a5a9b6d50c7 |
---|---|
376 } | 376 } |
377 | 377 |
378 QString | 378 QString |
379 FileFinder::find(FileType type, QString location, QString lastKnownLocation) | 379 FileFinder::find(FileType type, QString location, QString lastKnownLocation) |
380 { | 380 { |
381 if (QFileInfo(location).exists()) return location; | 381 if (FileSource::canHandleScheme(location)) { |
382 | |
383 if (FileSource::isRemote(location)) { | |
384 if (FileSource(location).isAvailable()) { | 382 if (FileSource(location).isAvailable()) { |
385 std::cerr << "FileFinder::find: ok, it's available... returning" << std::endl; | 383 std::cerr << "FileFinder::find: ok, it's available... returning" << std::endl; |
386 return location; | 384 return location; |
387 } | 385 } |
388 } | 386 } |
387 | |
388 if (QFileInfo(location).exists()) return location; | |
389 | 389 |
390 QString foundAt = ""; | 390 QString foundAt = ""; |
391 | 391 |
392 if ((foundAt = findRelative(location, lastKnownLocation)) != "") { | 392 if ((foundAt = findRelative(location, lastKnownLocation)) != "") { |
393 return foundAt; | 393 return foundAt; |
413 | 413 |
414 if (FileSource::isRemote(location)) { | 414 if (FileSource::isRemote(location)) { |
415 fileName = QUrl(location).path().section('/', -1, -1, | 415 fileName = QUrl(location).path().section('/', -1, -1, |
416 QString::SectionSkipEmpty); | 416 QString::SectionSkipEmpty); |
417 } else { | 417 } else { |
418 if (QUrl(location).scheme() == "file") { | |
419 location = QUrl(location).toLocalFile(); | |
420 } | |
418 fileName = QFileInfo(location).fileName(); | 421 fileName = QFileInfo(location).fileName(); |
419 } | 422 } |
420 | 423 |
421 if (FileSource::isRemote(relativeTo)) { | 424 if (FileSource::isRemote(relativeTo)) { |
422 resolved = QUrl(relativeTo).resolved(fileName).toString(); | 425 resolved = QUrl(relativeTo).resolved(fileName).toString(); |
423 if (!FileSource(resolved).isAvailable()) resolved = ""; | 426 if (!FileSource(resolved).isAvailable()) resolved = ""; |
424 std::cerr << "resolved: " << resolved.toStdString() << std::endl; | 427 std::cerr << "resolved: " << resolved.toStdString() << std::endl; |
425 } else { | 428 } else { |
429 if (QUrl(relativeTo).scheme() == "file") { | |
430 relativeTo = QUrl(relativeTo).toLocalFile(); | |
431 } | |
426 resolved = QFileInfo(relativeTo).dir().filePath(fileName); | 432 resolved = QFileInfo(relativeTo).dir().filePath(fileName); |
427 if (!QFileInfo(resolved).exists() || | 433 if (!QFileInfo(resolved).exists() || |
428 !QFileInfo(resolved).isFile() || | 434 !QFileInfo(resolved).isFile() || |
429 !QFileInfo(resolved).isReadable()) { | 435 !QFileInfo(resolved).isReadable()) { |
430 resolved = ""; | 436 resolved = ""; |