switch to using boost::filesystem
[mussa.git] / alg / nway_paths.cpp
index a71bda67e274ac53de6c3e12e01cf2728d7c4ed9..6c2acdf137da7ec87d3debb75d27627fa53a3e67 100644 (file)
 //                         ---------- mussa_nway.cc  -----------
 //                        ----------------------------------------
 
+#include <boost/filesystem/fstream.hpp>
+namespace fs = boost::filesystem;
+
 #include "alg/nway_paths.hpp"
 #include "alg/conserved_path.hpp"
 #include "mussa_exceptions.hpp"
 
-#include <fstream>
 #include <iostream>
 #include <stdexcept>
 
@@ -130,12 +132,12 @@ NwayPaths::add_path(ConservedPath loaded_path)
 
 
 void
-NwayPaths::save(string save_file_path)
+NwayPaths::save(fs::path save_file_path)
 {
-  fstream save_file;
+  fs::fstream save_file;
   list<ExtendedConservedPath >::iterator path_i, paths_end;
 
-  save_file.open(save_file_path.c_str(), ios::out);
+  save_file.open(save_file_path, ios::out);
 
   save_file << "<Mussa type=flp seq_count=" << sequence_count();
   save_file << " win=" << win_size;
@@ -180,18 +182,18 @@ NwayPaths::sequence_count()
 
 
 void
-NwayPaths::load(string load_file_path)
+NwayPaths::load(fs::path load_file_path)
 {
-  fstream load_file;
+  fs::fstream load_file;
   string file_data_line, header_data, data, path_node, path_width;
   int space_split_i, equal_split_i, comma_split_i, colon_split_i;
   vector<int> loaded_path;
 
-  load_file.open(load_file_path.c_str(), ios::in);
+  load_file.open(load_file_path, ios::in);
 
   if (!load_file)
   {
-    throw mussa_load_error("Sequence File: " + load_file_path + " not found");
+    throw mussa_load_error("Sequence File: " + load_file_path.string() + " not found");
   }
   else
   {
@@ -346,13 +348,13 @@ NwayPaths::find_paths_r(vector<vector<FLPs> > all_comparisons)
 
 
 void
-NwayPaths::save_old(string save_file_path)
+NwayPaths::save_old(fs::path save_file_path)
 {
-  fstream save_file;
+  fs::fstream save_file;
   list<ConservedPath >::iterator path_i, paths_end;
   size_t i;
 
-  save_file.open(save_file_path.c_str(), ios::app);
+  save_file.open(save_file_path, ios::app);
 
   path_i = pathz.begin();
   paths_end = pathz.end();