more fs::native for user supplied paths
authorDiane Trout <diane@caltech.edu>
Fri, 17 Nov 2006 23:19:49 +0000 (23:19 +0000)
committerDiane Trout <diane@caltech.edu>
Fri, 17 Nov 2006 23:19:49 +0000 (23:19 +0000)
ticket:237
Give boost::filesystem more hints about what filenames were entered by the
user and thus conforming to native file conventions.

alg/mussa.cpp
alg/parse_options.cpp
qui/MussaWindow.cpp

index 58558ff6e14b498c3679c7bcc4dfea41fc5223dc..f205fe4d0ab01b98019ea110f4f94a808e3d5a02 100644 (file)
@@ -635,8 +635,8 @@ Mussa::load(fs::path ana_file)
 
   analysis_path = ana_file;
   analysis_name = ana_path.leaf();
-  file_path_base =  ana_path.branch_path() / analysis_name;
-  a_file_path = file_path_base / (analysis_name + ".muway");
+  fs::path muway(analysis_name+".muway", fs::native);
+  a_file_path = analysis_path / muway;
   the_paths.load(a_file_path);
   // perhaps this could be more elegent, but at least this'll let
   // us know what our threshold and window sizes were when we load a muway
@@ -646,7 +646,8 @@ Mussa::load(fs::path ana_file)
 
   int seq_num = the_paths.sequence_count();
 
-  a_file_path = file_path_base / (analysis_name + ".museq");
+  fs::path museq(analysis_name + ".museq", fs::native);
+  a_file_path = analysis_path / museq;
 
   // this is a bit of a hack due to C++ not acting like it should with files
   for (i = 1; i <= seq_num; i++)
@@ -656,7 +657,8 @@ Mussa::load(fs::path ana_file)
     the_seqs.push_back(tmp_seq);
   }
   
-  fs::path motif_file = file_path_base / (analysis_name + ".mtl");
+  fs::path mtl(analysis_name + ".mtl", fs::native);
+  fs::path motif_file = analysis_path / mtl;
   if (fs::exists(motif_file)) {
     load_motifs(motif_file);
   }
@@ -675,15 +677,13 @@ Mussa::load(fs::path ana_file)
       append_info.str("");
       append_info << analysis_name <<  "_sp_" << i << "v" << i2 << ".flp";
       //clog << append_info.str() << endl;
-      a_file_path = file_path_base / append_info.str();
-      //clog << "path " << a_file_path.string() << endl;
+      fs::path flp(append_info.str(), fs::native);
+      a_file_path = analysis_path / flp;
       all_comps[i][i2].load(a_file_path);
-      //clog << "real size = " << all_comps[i][i2].size() << endl;
     }
   }
 }
 
-
 void
 Mussa::save_old()
 {
index b0d10626b2963692c66fb2947083fa29291bd26c..b911bbc6479cf2bfcef2b1c9f4a19d6fc9aab6ca 100644 (file)
@@ -1,5 +1,7 @@
 #include <boost/program_options.hpp>
 namespace po = boost::program_options;
+#include <boost/filesystem/path.hpp>
+namespace fs = boost::filesystem;
 
 #include <string>
 #include <iostream>
@@ -46,7 +48,8 @@ void initialize_mussa(MussaOptions& opts, int argc, char **argv)
   // currently we can only have one analysis loaded, so 
   // running trumps viewing.
   if (vm.count("run-analysis")) {
-    opts.analysis->load_mupa_file( vm["run-analysis"].as< std::string >() );
+    fs::path analysis_path(vm["run-analysis"].as< std::string >(), fs::native);
+    opts.analysis->load_mupa_file( analysis_path );
     std::cout << "I apologize for blocking the gui while running the analysis"
               << std::endl;
     opts.analysis->analyze();
@@ -54,10 +57,12 @@ void initialize_mussa(MussaOptions& opts, int argc, char **argv)
       opts.analysis->save();
   }
   else if (vm.count("view-analysis")) {
-    opts.analysis->load( vm["view-analysis"].as< std::string >() );
+    fs::path analysis_path(vm["view-analysis"].as< std::string >(), fs::native);
+    opts.analysis->load( analysis_path );
   }
   if (vm.count("motifs") and opts.analysis) {
-    opts.analysis->load_motifs( vm["motifs"].as< std::string >() );
+    fs::path motif_path(vm["motifs"].as< std::string >(), fs::native);
+    opts.analysis->load_motifs( motif_path );
   }
   if (vm.count("no-gui")) {
     opts.useGUI=false;
index 58fea508458d23fe3fdc975c42de47bff58ce8de..768d244569ceb610d793e9354edff9fd632738c2 100644 (file)
@@ -583,6 +583,12 @@ void MussaWindow::loadSavedAnalysis()
       win->default_dir->setPath(converted_path.branch_path().native_directory_string().c_str());
       win->show();
     }
+  } catch (boost::filesystem::filesystem_error e) {
+    QString msg("Unable to load ");
+    msg += muway_dir;
+    msg += "\n";
+    msg += e.what();
+    QMessageBox::warning(this, "Load Parameter", msg);    
   } catch (mussa_load_error e) {
     QString msg("Unable to load ");
     msg += muway_dir;