comparison document/SVFileReader.cpp @ 197:c08c312b2399

* Make RemoteFile far more pervasive, and use it for local files as well so that we can handle both transparently. Make it shallow copy with reference counting, so it can be used by value without having to worry about the cache file lifetime. Use RemoteFile for MainWindow file-open functions, etc
author Chris Cannam
date Thu, 18 Oct 2007 15:31:20 +0000
parents 7b943924b8d3
children 24ac2e4010c5
comparison
equal deleted inserted replaced
196:29c356da4ae4 197:c08c312b2399
410 WaveFileModel *model = 0; 410 WaveFileModel *model = 0;
411 FileFinder *ff = FileFinder::getInstance(); 411 FileFinder *ff = FileFinder::getInstance();
412 QString originalPath = attributes.value("file"); 412 QString originalPath = attributes.value("file");
413 QString path = ff->find(FileFinder::AudioFile, 413 QString path = ff->find(FileFinder::AudioFile,
414 originalPath, m_location); 414 originalPath, m_location);
415 QUrl url(path); 415
416 416 RemoteFile file(path);
417 if (RemoteFile::canHandleScheme(url)) { 417 file.waitForStatus();
418 418
419 RemoteFile rf(url); 419 if (!file.isOK()) {
420 rf.wait(); 420 std::cerr << "SVFileReader::readModel: Failed to retrieve file \"" << path.toStdString() << "\" for wave file model: " << file.getErrorString().toStdString() << std::endl;
421 421 } else if (!file.isAvailable()) {
422 if (rf.isOK()) { 422 std::cerr << "SVFileReader::readModel: Failed to retrieve file \"" << path.toStdString() << "\" for wave file model: Source unavailable" << std::endl;
423
424 model = new WaveFileModel(rf.getLocalFilename(), path);
425 if (!model->isOK()) {
426 delete model;
427 model = 0;
428 //!!! and delete local file?
429 }
430 }
431 } else { 423 } else {
432 424
433 model = new WaveFileModel(path); 425 file.waitForData();
426 model = new WaveFileModel(file);
434 if (!model->isOK()) { 427 if (!model->isOK()) {
435 delete model; 428 delete model;
436 model = 0; 429 model = 0;
437 } 430 }
438 } 431 }