Mercurial > hg > svcore
comparison data/fileio/FileFinder.cpp @ 317:c324d410b096
* RemoteFile -> FileSource
now it's used all over the place for local files as well.
| author | Chris Cannam |
|---|---|
| date | Thu, 18 Oct 2007 16:20:26 +0000 |
| parents | 3a6725f285d6 |
| children | a9ccd644f3bf |
comparison
equal
deleted
inserted
replaced
| 316:3a6725f285d6 | 317:c324d410b096 |
|---|---|
| 12 License, or (at your option) any later version. See the file | 12 License, or (at your option) any later version. See the file |
| 13 COPYING included with this distribution for more information. | 13 COPYING included with this distribution for more information. |
| 14 */ | 14 */ |
| 15 | 15 |
| 16 #include "FileFinder.h" | 16 #include "FileFinder.h" |
| 17 #include "RemoteFile.h" | 17 #include "FileSource.h" |
| 18 #include "AudioFileReaderFactory.h" | 18 #include "AudioFileReaderFactory.h" |
| 19 #include "DataFileReaderFactory.h" | 19 #include "DataFileReaderFactory.h" |
| 20 | 20 |
| 21 #include <QFileInfo> | 21 #include <QFileInfo> |
| 22 #include <QMessageBox> | 22 #include <QMessageBox> |
| 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 (QFileInfo(location).exists()) return location; |
| 382 | 382 |
| 383 if (RemoteFile::isRemote(location)) { | 383 if (FileSource::isRemote(location)) { |
| 384 if (RemoteFile(location).isAvailable()) { | 384 if (FileSource(location).isAvailable()) { |
| 385 std::cerr << "FileFinder::find: ok, it's available... returning" << std::endl; | 385 std::cerr << "FileFinder::find: ok, it's available... returning" << std::endl; |
| 386 return location; | 386 return location; |
| 387 } | 387 } |
| 388 } | 388 } |
| 389 | 389 |
| 409 << relativeTo.toStdString() << "\"..." << std::endl; | 409 << relativeTo.toStdString() << "\"..." << std::endl; |
| 410 | 410 |
| 411 QString fileName; | 411 QString fileName; |
| 412 QString resolved; | 412 QString resolved; |
| 413 | 413 |
| 414 if (RemoteFile::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 fileName = QFileInfo(location).fileName(); | 418 fileName = QFileInfo(location).fileName(); |
| 419 } | 419 } |
| 420 | 420 |
| 421 if (RemoteFile::isRemote(relativeTo)) { | 421 if (FileSource::isRemote(relativeTo)) { |
| 422 resolved = QUrl(relativeTo).resolved(fileName).toString(); | 422 resolved = QUrl(relativeTo).resolved(fileName).toString(); |
| 423 if (!RemoteFile(resolved).isAvailable()) resolved = ""; | 423 if (!FileSource(resolved).isAvailable()) resolved = ""; |
| 424 std::cerr << "resolved: " << resolved.toStdString() << std::endl; | 424 std::cerr << "resolved: " << resolved.toStdString() << std::endl; |
| 425 } else { | 425 } else { |
| 426 resolved = QFileInfo(relativeTo).dir().filePath(fileName); | 426 resolved = QFileInfo(relativeTo).dir().filePath(fileName); |
| 427 if (!QFileInfo(resolved).exists() || | 427 if (!QFileInfo(resolved).exists() || |
| 428 !QFileInfo(resolved).isFile() || | 428 !QFileInfo(resolved).isFile() || |
| 477 (0, tr("Use URL"), | 477 (0, tr("Use URL"), |
| 478 tr("Please enter the URL to use for this file:"), | 478 tr("Please enter the URL to use for this file:"), |
| 479 QLineEdit::Normal, "", &ok); | 479 QLineEdit::Normal, "", &ok); |
| 480 | 480 |
| 481 if (ok && path != "") { | 481 if (ok && path != "") { |
| 482 if (RemoteFile(path).isAvailable()) { | 482 if (FileSource(path).isAvailable()) { |
| 483 done = true; | 483 done = true; |
| 484 } else { | 484 } else { |
| 485 QMessageBox::critical | 485 QMessageBox::critical |
| 486 (0, tr("Failed to open location"), | 486 (0, tr("Failed to open location"), |
| 487 tr("URL \"%1\" could not be opened").arg(path)); | 487 tr("URL \"%1\" could not be opened").arg(path)); |
