diff data/fileio/FileFinder.cpp @ 316:3a6725f285d6

* 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 fc656505c573
children c324d410b096
line wrap: on
line diff
--- a/data/fileio/FileFinder.cpp	Thu Oct 18 10:24:26 2007 +0000
+++ b/data/fileio/FileFinder.cpp	Thu Oct 18 15:31:20 2007 +0000
@@ -380,11 +380,11 @@
 {
     if (QFileInfo(location).exists()) return location;
 
-    if (RemoteFile::canHandleScheme(QUrl(location))) {
-        RemoteFile rf(location);
-        bool available = rf.isAvailable();
-        rf.deleteLocalFile();
-        if (available) return location;
+    if (RemoteFile::isRemote(location)) {
+        if (RemoteFile(location).isAvailable()) {
+            std::cerr << "FileFinder::find: ok, it's available... returning" << std::endl;
+            return location;
+        }
     }
 
     QString foundAt = "";
@@ -411,19 +411,17 @@
     QString fileName;
     QString resolved;
 
-    if (RemoteFile::canHandleScheme(QUrl(location))) {
+    if (RemoteFile::isRemote(location)) {
         fileName = QUrl(location).path().section('/', -1, -1,
                                                  QString::SectionSkipEmpty);
     } else {
         fileName = QFileInfo(location).fileName();
     }
 
-    if (RemoteFile::canHandleScheme(QUrl(relativeTo))) {
+    if (RemoteFile::isRemote(relativeTo)) {
         resolved = QUrl(relativeTo).resolved(fileName).toString();
-        RemoteFile rf(resolved);
-        if (!rf.isAvailable()) resolved = "";
+        if (!RemoteFile(resolved).isAvailable()) resolved = "";
         std::cerr << "resolved: " << resolved.toStdString() << std::endl;
-        rf.deleteLocalFile();
     } else {
         resolved = QFileInfo(relativeTo).dir().filePath(fileName);
         if (!QFileInfo(resolved).exists() ||
@@ -481,8 +479,7 @@
                  QLineEdit::Normal, "", &ok);
 
             if (ok && path != "") {
-                RemoteFile rf(path);
-                if (rf.isAvailable()) {
+                if (RemoteFile(path).isAvailable()) {
                     done = true;
                 } else {
                     QMessageBox::critical
@@ -490,7 +487,6 @@
                          tr("URL \"%1\" could not be opened").arg(path));
                     path = "";
                 }
-                rf.deleteLocalFile();
             }
             break;
         }