More string -> boost::filesystem::path.
authorCarl Hetherington <cth@carlh.net>
Sat, 19 Oct 2013 13:43:31 +0000 (14:43 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 19 Oct 2013 13:43:31 +0000 (14:43 +0100)
src/lib/dcp_video_frame.cc
src/lib/dcp_video_frame.h
src/lib/film.cc
src/lib/film.h
src/lib/log.cc
src/lib/log.h
src/lib/scp_dcp_job.cc

index 1c812cbf25c90a2e31a4176f6b4a43aea719a594..477bdae14f86723e849f53d6c1dc6e9929042acf 100644 (file)
@@ -326,7 +326,7 @@ EncodedData::EncodedData (int s)
 
 }
 
-EncodedData::EncodedData (string file)
+EncodedData::EncodedData (boost::filesystem::path file)
 {
        _size = boost::filesystem::file_size (file);
        _data = new uint8_t[_size];
@@ -358,7 +358,7 @@ EncodedData::~EncodedData ()
 void
 EncodedData::write (shared_ptr<const Film> film, int frame, Eyes eyes) const
 {
-       string const tmp_j2c = film->j2c_path (frame, eyes, true);
+       boost::filesystem::path const tmp_j2c = film->j2c_path (frame, eyes, true);
 
        FILE* f = fopen (tmp_j2c.c_str (), N_("wb"));
        
@@ -369,7 +369,7 @@ EncodedData::write (shared_ptr<const Film> film, int frame, Eyes eyes) const
        fwrite (_data, 1, _size, f);
        fclose (f);
 
-       string const real_j2c = film->j2c_path (frame, eyes, false);
+       boost::filesystem::path const real_j2c = film->j2c_path (frame, eyes, false);
 
        /* Rename the file from foo.j2c.tmp to foo.j2c now that it is complete */
        boost::filesystem::rename (tmp_j2c, real_j2c);
@@ -378,7 +378,7 @@ EncodedData::write (shared_ptr<const Film> film, int frame, Eyes eyes) const
 void
 EncodedData::write_info (shared_ptr<const Film> film, int frame, Eyes eyes, libdcp::FrameInfo fin) const
 {
-       string const info = film->info_path (frame, eyes);
+       boost::filesystem::path const info = film->info_path (frame, eyes);
        ofstream h (info.c_str());
        fin.write (h);
 }
index bf0b7f8c4614da1237f91adada7e30ba002a907f..c642fb4db842446ea5a03421d7e9104ce8f1b491 100644 (file)
@@ -43,7 +43,7 @@ public:
        /** @param s Size of data, in bytes */
        EncodedData (int s);
 
-       EncodedData (std::string f);
+       EncodedData (boost::filesystem::path);
 
        virtual ~EncodedData ();
 
index bb210350e6fae4f4dc3baef7e1ee53db6f70be72..2697b062fb8211be7d4838e421f4359a134b2e2e 100644 (file)
@@ -165,34 +165,34 @@ Film::video_identifier () const
 }
          
 /** @return The path to the directory to write video frame info files to */
-string
+boost::filesystem::path
 Film::info_dir () const
 {
        boost::filesystem::path p;
        p /= "info";
        p /= video_identifier ();
-       return dir (p.string());
+       return dir (p);
 }
 
-string
+boost::filesystem::path
 Film::internal_video_mxf_dir () const
 {
        return dir ("video");
 }
 
-string
+boost::filesystem::path
 Film::internal_video_mxf_filename () const
 {
        return video_identifier() + ".mxf";
 }
 
-string
+boost::filesystem::path
 Film::video_mxf_filename () const
 {
        return filename_safe_name() + "_video.mxf";
 }
 
-string
+boost::filesystem::path
 Film::audio_mxf_filename () const
 {
        return filename_safe_name() + "_audio.mxf";
@@ -351,7 +351,7 @@ Film::write_metadata () const
        root->add_child("Key")->add_child_text (_key.hex ());
        _playlist->as_xml (root->add_child ("Playlist"));
 
-       doc.write_to_file_formatted (file ("metadata.xml"));
+       doc.write_to_file_formatted (file("metadata.xml").string ());
        
        _dirty = false;
 }
@@ -407,8 +407,8 @@ Film::read_metadata ()
 /** Given a directory name, return its full path within the Film's directory.
  *  The directory (and its parents) will be created if they do not exist.
  */
-string
-Film::dir (string d) const
+boost::filesystem::path
+Film::dir (boost::filesystem::path d) const
 {
        boost::filesystem::path p;
        p /= _directory;
@@ -416,14 +416,14 @@ Film::dir (string d) const
        
        boost::filesystem::create_directories (p);
        
-       return p.string ();
+       return p;
 }
 
 /** Given a file or directory name, return its full path within the Film's directory.
  *  Any required parent directories will be created.
  */
-string
-Film::file (string f) const
+boost::filesystem::path
+Film::file (boost::filesystem::path f) const
 {
        boost::filesystem::path p;
        p /= _directory;
@@ -431,7 +431,7 @@ Film::file (string f) const
 
        boost::filesystem::create_directories (p.parent_path ());
        
-       return p.string ();
+       return p;
 }
 
 /** @return a DCI-compliant name for a DCP of this film */
@@ -671,7 +671,7 @@ Film::set_dci_date_today ()
        _dci_date = boost::gregorian::day_clock::local_day ();
 }
 
-string
+boost::filesystem::path
 Film::info_path (int f, Eyes e) const
 {
        boost::filesystem::path p;
@@ -694,10 +694,10 @@ Film::info_path (int f, Eyes e) const
        /* info_dir() will already have added any initial bit of the path,
           so don't call file() on this.
        */
-       return p.string ();
+       return p;
 }
 
-string
+boost::filesystem::path
 Film::j2c_path (int f, Eyes e, bool t) const
 {
        boost::filesystem::path p;
@@ -721,7 +721,7 @@ Film::j2c_path (int f, Eyes e, bool t) const
        }
 
        p /= s.str();
-       return file (p.string ());
+       return file (p);
 }
 
 /** @return List of subdirectories (not full paths) containing DCPs that can be successfully libdcp::DCP::read() */
index eb9130de39097d3a85baa9aa465474bfc6c51906..8cfc490886629ea99c3cc5e0cddd07b7932ceb7a 100644 (file)
@@ -58,15 +58,15 @@ class Film : public boost::enable_shared_from_this<Film>, public boost::noncopya
 public:
        Film (boost::filesystem::path);
 
-       std::string info_dir () const;
-       std::string j2c_path (int, Eyes, bool) const;
-       std::string info_path (int, Eyes) const;
-       std::string internal_video_mxf_dir () const;
-       std::string internal_video_mxf_filename () const;
+       boost::filesystem::path info_dir () const;
+       boost::filesystem::path j2c_path (int, Eyes, bool) const;
+       boost::filesystem::path info_path (int, Eyes) const;
+       boost::filesystem::path internal_video_mxf_dir () const;
+       boost::filesystem::path internal_video_mxf_filename () const;
        boost::filesystem::path audio_analysis_path (boost::shared_ptr<const AudioContent>) const;
 
-       std::string video_mxf_filename () const;
-       std::string audio_mxf_filename () const;
+       boost::filesystem::path video_mxf_filename () const;
+       boost::filesystem::path audio_mxf_filename () const;
 
        void send_dcp_to_tms ();
        void make_dcp ();
@@ -80,8 +80,8 @@ public:
 
        int encoded_frames () const;
        
-       std::string file (std::string f) const;
-       std::string dir (std::string d) const;
+       boost::filesystem::path file (boost::filesystem::path f) const;
+       boost::filesystem::path dir (boost::filesystem::path d) const;
 
        void read_metadata ();
        void write_metadata () const;
index ef36a902cbbc76027982bc8a054630ca1e693d38..d50769dfe40b6f6508da7ebf94983974511ccc3c 100644 (file)
@@ -93,7 +93,7 @@ Log::set_level (string l)
 }
 
 /** @param file Filename to write log to */
-FileLog::FileLog (string file)
+FileLog::FileLog (boost::filesystem::path file)
        : _file (file)
 {
 
index bd0066a83baee699582c61febc5c5738dba408eb..6a911b13f29c64dd742beef1eee54a6b6429e0e1 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <string>
 #include <boost/thread/mutex.hpp>
+#include <boost/filesystem.hpp>
 
 /** @class Log
  *  @brief A very simple logging class.
@@ -62,12 +63,12 @@ private:
 class FileLog : public Log
 {
 public:
-       FileLog (std::string file);
+       FileLog (boost::filesystem::path file);
 
 private:
        void do_log (std::string m);
        /** filename to write to */
-       std::string _file;
+       boost::filesystem::path _file;
 };
 
 #endif
index 528d393a36d73e559e0ca8b9d45b1e973ea87a3a..779c8dd44b2abf131ea8490c73c4f17f8b155ef1 100644 (file)
@@ -150,7 +150,7 @@ SCPDCPJob::run ()
                throw NetworkError (String::compose (_("Could not create remote directory %1 (%2)"), _film->dcp_name(), ssh_get_error (ss.session)));
        }
        
-       string const dcp_dir = _film->dir (_film->dcp_name());
+       boost::filesystem::path const dcp_dir = _film->dir (_film->dcp_name());
        
        boost::uintmax_t bytes_to_transfer = 0;
        for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (dcp_dir); i != boost::filesystem::directory_iterator(); ++i) {