From 6543d9a51b31ce24726187d9d1b018f05f09ef40 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 19 Oct 2013 14:43:31 +0100 Subject: [PATCH] More string -> boost::filesystem::path. --- src/lib/dcp_video_frame.cc | 8 ++++---- src/lib/dcp_video_frame.h | 2 +- src/lib/film.cc | 34 +++++++++++++++++----------------- src/lib/film.h | 18 +++++++++--------- src/lib/log.cc | 2 +- src/lib/log.h | 5 +++-- src/lib/scp_dcp_job.cc | 2 +- 7 files changed, 36 insertions(+), 35 deletions(-) diff --git a/src/lib/dcp_video_frame.cc b/src/lib/dcp_video_frame.cc index 1c812cbf2..477bdae14 100644 --- a/src/lib/dcp_video_frame.cc +++ b/src/lib/dcp_video_frame.cc @@ -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 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 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 film, int frame, Eyes eyes) const void EncodedData::write_info (shared_ptr 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); } diff --git a/src/lib/dcp_video_frame.h b/src/lib/dcp_video_frame.h index bf0b7f8c4..c642fb4db 100644 --- a/src/lib/dcp_video_frame.h +++ b/src/lib/dcp_video_frame.h @@ -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 (); diff --git a/src/lib/film.cc b/src/lib/film.cc index bb210350e..2697b062f 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -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() */ diff --git a/src/lib/film.h b/src/lib/film.h index eb9130de3..8cfc49088 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -58,15 +58,15 @@ class Film : public boost::enable_shared_from_this, 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; - 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; diff --git a/src/lib/log.cc b/src/lib/log.cc index ef36a902c..d50769dfe 100644 --- a/src/lib/log.cc +++ b/src/lib/log.cc @@ -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) { diff --git a/src/lib/log.h b/src/lib/log.h index bd0066a83..6a911b13f 100644 --- a/src/lib/log.h +++ b/src/lib/log.h @@ -26,6 +26,7 @@ #include #include +#include /** @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 diff --git a/src/lib/scp_dcp_job.cc b/src/lib/scp_dcp_job.cc index 528d393a3..779c8dd44 100644 --- a/src/lib/scp_dcp_job.cc +++ b/src/lib/scp_dcp_job.cc @@ -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) { -- 2.30.2