From f0f4dd5e6b6ed5e50d0444a4de3b2a13156edf64 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 6 Oct 2023 02:37:16 +0200 Subject: Use dcp::filesystem to wrap filesystem calls and fix_long_path anything that is passed to read_file() from libcxml. This should fix #2623 and other similar problems. --- src/lib/analytics.cc | 3 +- src/lib/audio_analysis.cc | 2 +- src/lib/config.cc | 48 +++++++++++++++---------------- src/lib/content.cc | 12 ++++---- src/lib/content_factory.cc | 13 +++++---- src/lib/cross_linux.cc | 5 ++-- src/lib/ffmpeg_encoder.cc | 4 +-- src/lib/file_group.cc | 7 +++-- src/lib/file_log.cc | 3 +- src/lib/film.cc | 57 +++++++++++++------------------------ src/lib/find_missing.cc | 10 +++---- src/lib/font_config.cc | 3 +- src/lib/hints.cc | 11 +++---- src/lib/image_content.cc | 7 +++-- src/lib/image_examiner.cc | 3 +- src/lib/job.cc | 6 ++-- src/lib/kdm_cli.cc | 7 +++-- src/lib/kdm_with_metadata.cc | 25 ++++++++-------- src/lib/map_cli.cc | 17 +++++------ src/lib/reel_writer.cc | 25 ++++++++-------- src/lib/scoped_temporary.cc | 7 +++-- src/lib/scp_uploader.cc | 3 +- src/lib/spl.cc | 3 +- src/lib/state.cc | 9 +++--- src/lib/subtitle_analysis.cc | 3 +- src/lib/subtitle_encoder.cc | 5 ++-- src/lib/types.cc | 3 +- src/lib/util.cc | 19 +++++++------ src/lib/writer.cc | 8 +++--- src/lib/zipper.cc | 9 +++--- src/tools/dcpomatic.cc | 11 +++---- src/tools/dcpomatic_batch.cc | 5 ++-- src/tools/dcpomatic_cli.cc | 3 +- src/tools/dcpomatic_create.cc | 5 ++-- src/tools/dcpomatic_kdm.cc | 3 +- src/tools/dcpomatic_player.cc | 5 ++-- src/tools/dcpomatic_playlist.cc | 5 ++-- src/wx/audio_dialog.cc | 5 ++-- src/wx/config_dialog.cc | 3 +- src/wx/content_panel.cc | 5 ++-- src/wx/content_view.cc | 3 +- src/wx/film_name_location_dialog.cc | 2 +- src/wx/fonts_dialog.cc | 3 +- src/wx/full_config_dialog.cc | 5 ++-- src/wx/kdm_cpl_panel.cc | 2 +- src/wx/system_font_dialog.cc | 3 +- src/wx/text_panel.cc | 5 ++-- test/test.cc | 3 +- test/zipper_test.cc | 6 ++++ 49 files changed, 221 insertions(+), 198 deletions(-) diff --git a/src/lib/analytics.cc b/src/lib/analytics.cc index 75146cb45..836051fe5 100644 --- a/src/lib/analytics.cc +++ b/src/lib/analytics.cc @@ -22,6 +22,7 @@ #include "analytics.h" #include "compose.hpp" #include "exceptions.h" +#include #include #include #include @@ -110,7 +111,7 @@ Analytics::read () try { cxml::Document f ("Analytics"); - f.read_file (read_path("analytics.xml")); + f.read_file(dcp::filesystem::fix_long_path(read_path("analytics.xml"))); _successful_dcp_encodes = f.number_child("SuccessfulDCPEncodes"); } catch (...) { /* Never mind */ diff --git a/src/lib/audio_analysis.cc b/src/lib/audio_analysis.cc index 6f1bb2375..b8c2e072d 100644 --- a/src/lib/audio_analysis.cc +++ b/src/lib/audio_analysis.cc @@ -66,7 +66,7 @@ AudioAnalysis::AudioAnalysis (int channels) AudioAnalysis::AudioAnalysis (boost::filesystem::path filename) { cxml::Document f ("AudioAnalysis"); - f.read_file (filename); + f.read_file(dcp::filesystem::fix_long_path(filename)); if (f.optional_number_child("Version").get_value_or(1) < _current_state_version) { /* Too old. Throw an exception so that this analysis is re-run. */ diff --git a/src/lib/config.cc b/src/lib/config.cc index fdce75109..063fbcab9 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -291,7 +291,7 @@ Config::read_config() try { cxml::Document f ("Config"); - f.read_file (config_read_file()); + f.read_file(dcp::filesystem::fix_long_path(config_read_file())); auto version = f.optional_number_child ("Version"); if (version && *version < _current_version) { @@ -654,10 +654,10 @@ catch (...) { void Config::read_cinemas() { - if (boost::filesystem::exists (_cinemas_file)) { + if (dcp::filesystem::exists(_cinemas_file)) { try { cxml::Document f("Cinemas"); - f.read_file(_cinemas_file); + f.read_file(dcp::filesystem::fix_long_path(_cinemas_file)); read_cinemas(f); } catch (...) { backup(); @@ -671,10 +671,10 @@ Config::read_cinemas() void Config::read_dkdm_recipients() { - if (boost::filesystem::exists (_dkdm_recipients_file)) { + if (dcp::filesystem::exists(_dkdm_recipients_file)) { try { cxml::Document f("DKDMRecipients"); - f.read_file(_dkdm_recipients_file); + f.read_file(dcp::filesystem::fix_long_path(_dkdm_recipients_file)); read_dkdm_recipients(f); } catch (...) { backup(); @@ -1133,8 +1133,8 @@ Config::write_config () const } f.checked_write(s.c_str(), s.bytes()); f.close(); - boost::filesystem::remove (target); - boost::filesystem::rename (tmp, target); + dcp::filesystem::remove(target); + dcp::filesystem::rename(tmp, target); } catch (xmlpp::exception& e) { string s = e.what (); trim (s); @@ -1157,8 +1157,8 @@ write_file (string root_node, string node, string version, list> t try { doc.write_to_file_formatted (file.string() + ".tmp"); - boost::filesystem::remove (file); - boost::filesystem::rename (file.string() + ".tmp", file); + dcp::filesystem::remove(file); + dcp::filesystem::rename(file.string() + ".tmp", file); } catch (xmlpp::exception& e) { string s = e.what (); trim (s); @@ -1201,7 +1201,7 @@ Config::directory_or (optional dir, boost::filesystem:: } boost::system::error_code ec; - auto const e = boost::filesystem::exists (*dir, ec); + auto const e = dcp::filesystem::exists(*dir, ec); if (ec || !e) { return a; } @@ -1324,7 +1324,7 @@ Config::clean_history_internal (vector& h) h.clear (); for (auto i: old) { try { - if (boost::filesystem::is_directory(i)) { + if (dcp::filesystem::is_directory(i)) { h.push_back (i); } } catch (...) { @@ -1337,7 +1337,7 @@ Config::clean_history_internal (vector& h) bool Config::have_existing (string file) { - return boost::filesystem::exists (read_path(file)); + return dcp::filesystem::exists(read_path(file)); } @@ -1364,10 +1364,10 @@ Config::set_cinemas_file (boost::filesystem::path file) _cinemas_file = file; - if (boost::filesystem::exists (_cinemas_file)) { + if (dcp::filesystem::exists(_cinemas_file)) { /* Existing file; read it in */ cxml::Document f ("Cinemas"); - f.read_file (_cinemas_file); + f.read_file(dcp::filesystem::fix_long_path(_cinemas_file)); read_cinemas (f); } @@ -1396,12 +1396,12 @@ Config::save_template (shared_ptr film, string name) const list Config::templates () const { - if (!boost::filesystem::exists(read_path("templates"))) { + if (!dcp::filesystem::exists(read_path("templates"))) { return {}; } list n; - for (auto const& i: boost::filesystem::directory_iterator(read_path("templates"))) { + for (auto const& i: dcp::filesystem::directory_iterator(read_path("templates"))) { n.push_back (i.path().filename().string()); } return n; @@ -1410,7 +1410,7 @@ Config::templates () const bool Config::existing_template (string name) const { - return boost::filesystem::exists (template_read_path(name)); + return dcp::filesystem::exists(template_read_path(name)); } @@ -1431,13 +1431,13 @@ Config::template_write_path (string name) const void Config::rename_template (string old_name, string new_name) const { - boost::filesystem::rename (template_read_path(old_name), template_write_path(new_name)); + dcp::filesystem::rename(template_read_path(old_name), template_write_path(new_name)); } void Config::delete_template (string name) const { - boost::filesystem::remove (template_write_path(name)); + dcp::filesystem::remove(template_write_path(name)); } /** @return Path to the config.xml containing the actual settings, following a link if required */ @@ -1445,14 +1445,14 @@ boost::filesystem::path config_file (boost::filesystem::path main) { cxml::Document f ("Config"); - if (!boost::filesystem::exists (main)) { + if (!dcp::filesystem::exists(main)) { /* It doesn't exist, so there can't be any links; just return it */ return main; } /* See if there's a link */ try { - f.read_file (main); + f.read_file(dcp::filesystem::fix_long_path(main)); auto link = f.optional_string_child("Link"); if (link) { return *link; @@ -1506,7 +1506,7 @@ void Config::copy_and_link (boost::filesystem::path new_file) const { write (); - boost::filesystem::copy_file (config_read_file(), new_file, boost::filesystem::copy_option::overwrite_if_exists); + dcp::filesystem::copy_file(config_read_file(), new_file, boost::filesystem::copy_option::overwrite_if_exists); link (new_file); } @@ -1611,10 +1611,10 @@ save_all_config_as_zip (boost::filesystem::path zip_file) auto config = Config::instance(); zipper.add ("config.xml", dcp::file_to_string(config->config_read_file())); - if (boost::filesystem::exists(config->cinemas_file())) { + if (dcp::filesystem::exists(config->cinemas_file())) { zipper.add ("cinemas.xml", dcp::file_to_string(config->cinemas_file())); } - if (boost::filesystem::exists(config->dkdm_recipients_file())) { + if (dcp::filesystem::exists(config->dkdm_recipients_file())) { zipper.add ("dkdm_recipients.xml", dcp::file_to_string(config->dkdm_recipients_file())); } diff --git a/src/lib/content.cc b/src/lib/content.cc index 97edc7c89..6324050ec 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -93,7 +93,7 @@ Content::Content (cxml::ConstNodePtr node) _last_write_times.push_back (*mod); } else { boost::system::error_code ec; - auto last_write = boost::filesystem::last_write_time(i->content(), ec); + auto last_write = dcp::filesystem::last_write_time(i->content(), ec); _last_write_times.push_back (ec ? 0 : last_write); } } @@ -187,7 +187,7 @@ Content::examine (shared_ptr, shared_ptr job) _last_write_times.clear (); for (auto i: _paths) { boost::system::error_code ec; - auto last_write = boost::filesystem::last_write_time(i, ec); + auto last_write = dcp::filesystem::last_write_time(i, ec); _last_write_times.push_back (ec ? 0 : last_write); } } @@ -339,7 +339,7 @@ bool Content::paths_valid () const { for (auto i: _paths) { - if (!boost::filesystem::exists (i)) { + if (!dcp::filesystem::exists(i)) { return false; } } @@ -359,7 +359,7 @@ Content::set_paths (vector paths) _last_write_times.clear (); for (auto i: _paths) { boost::system::error_code ec; - auto last_write = boost::filesystem::last_write_time(i, ec); + auto last_write = dcp::filesystem::last_write_time(i, ec); _last_write_times.push_back (ec ? 0 : last_write); } } @@ -552,7 +552,7 @@ Content::add_path (boost::filesystem::path p) boost::mutex::scoped_lock lm (_mutex); _paths.push_back (p); boost::system::error_code ec; - auto last_write = boost::filesystem::last_write_time(p, ec); + auto last_write = dcp::filesystem::last_write_time(p, ec); _last_write_times.push_back (ec ? 0 : last_write); } @@ -562,7 +562,7 @@ Content::changed () const { bool write_time_changed = false; for (auto i = 0U; i < _paths.size(); ++i) { - if (boost::filesystem::last_write_time(_paths[i]) != last_write_time(i)) { + if (dcp::filesystem::last_write_time(_paths[i]) != last_write_time(i)) { write_time_changed = true; break; } diff --git a/src/lib/content_factory.cc b/src/lib/content_factory.cc index b23a088b4..e1278c3b4 100644 --- a/src/lib/content_factory.cc +++ b/src/lib/content_factory.cc @@ -40,6 +40,7 @@ #include "log.h" #include "compose.hpp" #include +#include #include #include @@ -111,11 +112,11 @@ content_factory (boost::filesystem::path path) { vector> content; - if (boost::filesystem::is_directory (path)) { + if (dcp::filesystem::is_directory(path)) { LOG_GENERAL ("Look in directory %1", path); - if (boost::filesystem::is_empty (path)) { + if (dcp::filesystem::is_empty(path)) { return content; } @@ -124,7 +125,7 @@ content_factory (boost::filesystem::path path) int image_files = 0; int sound_files = 0; int read = 0; - for (boost::filesystem::directory_iterator i(path); i != boost::filesystem::directory_iterator() && read < 10; ++i) { + for (dcp::filesystem::directory_iterator i(path); i != dcp::filesystem::directory_iterator() && read < 10; ++i) { LOG_GENERAL ("Checking file %1", i->path()); @@ -134,7 +135,7 @@ content_factory (boost::filesystem::path path) continue; } - if (!boost::filesystem::is_regular_file(i->path())) { + if (!dcp::filesystem::is_regular_file(i->path())) { /* Ignore things which aren't files (probably directories) */ LOG_GENERAL ("Ignored %1 (not a regular file)", i->path()); continue; @@ -154,7 +155,7 @@ content_factory (boost::filesystem::path path) if (image_files > 0 && sound_files == 0) { content.push_back (make_shared(path)); } else if (image_files == 0 && sound_files > 0) { - for (auto i: boost::filesystem::directory_iterator(path)) { + for (auto i: dcp::filesystem::directory_iterator(path)) { content.push_back (make_shared(i.path())); } } @@ -172,7 +173,7 @@ content_factory (boost::filesystem::path path) single = make_shared(path); } else if (ext == ".xml") { cxml::Document doc; - doc.read_file (path); + doc.read_file(dcp::filesystem::fix_long_path(path)); if (doc.root_name() == "DCinemaSecurityMessage") { throw KDMAsContentError (); } diff --git a/src/lib/cross_linux.cc b/src/lib/cross_linux.cc index 0a12d7cca..015158aa8 100644 --- a/src/lib/cross_linux.cc +++ b/src/lib/cross_linux.cc @@ -26,6 +26,7 @@ #include "dcpomatic_log.h" #include "exceptions.h" #include "log.h" +#include #include #include #include @@ -94,7 +95,7 @@ libdcp_resources_path () if (auto appdir = getenv("APPDIR")) { return boost::filesystem::path(appdir) / "usr" / "share" / "libdcp"; } - return boost::filesystem::canonical(LINUX_SHARE_PREFIX) / "libdcp"; + return dcp::filesystem::canonical(LINUX_SHARE_PREFIX) / "libdcp"; } @@ -153,7 +154,7 @@ boost::filesystem::path openssl_path () { auto p = directory_containing_executable() / "dcpomatic2_openssl"; - if (boost::filesystem::is_regular_file(p)) { + if (dcp::filesystem::is_regular_file(p)) { return p; } diff --git a/src/lib/ffmpeg_encoder.cc b/src/lib/ffmpeg_encoder.cc index 00ad75526..60241b233 100644 --- a/src/lib/ffmpeg_encoder.cc +++ b/src/lib/ffmpeg_encoder.cc @@ -144,8 +144,8 @@ FFmpegEncoder::go () for (int i = 0; i < files; ++i) { boost::filesystem::path filename = _output; - string extension = boost::filesystem::extension (filename); - filename = boost::filesystem::change_extension (filename, ""); + auto extension = dcp::filesystem::extension(filename); + filename = dcp::filesystem::change_extension(filename, ""); if (files > 1) { /// TRANSLATORS: _reel%1 here is to be added to an export filename to indicate diff --git a/src/lib/file_group.cc b/src/lib/file_group.cc index f4d50028e..228faa74d 100644 --- a/src/lib/file_group.cc +++ b/src/lib/file_group.cc @@ -29,6 +29,7 @@ #include "dcpomatic_assert.h" #include "exceptions.h" #include "file_group.h" +#include #include #include @@ -88,7 +89,7 @@ FileGroup::ensure_open_path (size_t p) const if (!_current_file) { throw OpenFileError (_paths[_current_path], errno, OpenFileError::READ); } - _current_size = boost::filesystem::file_size (_paths[_current_path]); + _current_size = dcp::filesystem::file_size(_paths[_current_path]); } @@ -111,7 +112,7 @@ FileGroup::seek (int64_t pos, int whence) const size_t i = 0; int64_t sub_pos = _position; while (i < _paths.size()) { - boost::uintmax_t len = boost::filesystem::file_size (_paths[i]); + boost::uintmax_t len = dcp::filesystem::file_size(_paths[i]); if (sub_pos < int64_t(len)) { break; } @@ -188,7 +189,7 @@ FileGroup::length () const { int64_t len = 0; for (size_t i = 0; i < _paths.size(); ++i) { - len += boost::filesystem::file_size (_paths[i]); + len += dcp::filesystem::file_size(_paths[i]); } return len; diff --git a/src/lib/file_log.cc b/src/lib/file_log.cc index adb06b7f0..5265e2a9d 100644 --- a/src/lib/file_log.cc +++ b/src/lib/file_log.cc @@ -23,6 +23,7 @@ #include "cross.h" #include "config.h" #include +#include #include #include #include @@ -70,7 +71,7 @@ FileLog::head_and_tail (int amount) const uintmax_t head_amount = amount; uintmax_t tail_amount = amount; boost::system::error_code ec; - uintmax_t size = boost::filesystem::file_size (_file, ec); + uintmax_t size = dcp::filesystem::file_size(_file, ec); if (size == static_cast(-1)) { return ""; } diff --git a/src/lib/film.cc b/src/lib/film.cc index 803dbb732..a6d10b9bf 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -63,6 +63,7 @@ #include #include #include +#include #include #include #include @@ -205,27 +206,7 @@ Film::Film (optional dir) _playlist_length_change_connection = _playlist->LengthChange.connect (bind(&Film::playlist_length_change, this)); if (dir) { - /* Make state.directory a complete path without ..s (where possible) - (Code swiped from Adam Bowen on stackoverflow) - XXX: couldn't/shouldn't this just be boost::filesystem::canonical? - */ - - boost::filesystem::path p (boost::filesystem::system_complete (dir.get())); - boost::filesystem::path result; - for (auto i: p) { - if (i == "..") { - boost::system::error_code ec; - if (boost::filesystem::is_symlink(result, ec) || result.filename() == "..") { - result /= i; - } else { - result = result.parent_path (); - } - } else if (i != ".") { - result /= i; - } - } - - set_directory (result.make_preferred ()); + set_directory(dcp::filesystem::weakly_canonical(*dir)); } if (_directory) { @@ -494,7 +475,7 @@ void Film::write_metadata () { DCPOMATIC_ASSERT (directory()); - boost::filesystem::create_directories (directory().get()); + dcp::filesystem::create_directories(directory().get()); auto const filename = file(metadata_file); try { metadata()->write_to_file_formatted(filename.string()); @@ -508,7 +489,7 @@ Film::write_metadata () void Film::write_template (boost::filesystem::path path) const { - boost::filesystem::create_directories (path.parent_path()); + dcp::filesystem::create_directories(path.parent_path()); shared_ptr doc = metadata (false); metadata(false)->write_to_file_formatted(path.string()); } @@ -520,19 +501,19 @@ list Film::read_metadata (optional path) { if (!path) { - if (boost::filesystem::exists (file ("metadata")) && !boost::filesystem::exists (file (metadata_file))) { + if (dcp::filesystem::exists(file("metadata")) && !dcp::filesystem::exists(file(metadata_file))) { throw runtime_error (_("This film was created with an older version of DCP-o-matic, and unfortunately it cannot be loaded into this version. You will need to create a new Film, re-add your content and set it up again. Sorry!")); } path = file (metadata_file); } - if (!boost::filesystem::exists(*path)) { + if (!dcp::filesystem::exists(*path)) { throw FileNotFoundError(*path); } cxml::Document f ("Metadata"); - f.read_file (path.get ()); + f.read_file(dcp::filesystem::fix_long_path(path.get())); _state_version = f.number_child ("Version"); if (_state_version > current_state_version) { @@ -540,9 +521,9 @@ Film::read_metadata (optional path) } else if (_state_version < current_state_version) { /* This is an older version; save a copy (if we haven't already) */ auto const older = path->parent_path() / String::compose("metadata.%1.xml", _state_version); - if (!boost::filesystem::is_regular_file(older)) { + if (!dcp::filesystem::is_regular_file(older)) { try { - boost::filesystem::copy_file(*path, older); + dcp::filesystem::copy_file(*path, older); } catch (...) { /* Never mind; at least we tried */ } @@ -740,7 +721,7 @@ Film::dir (boost::filesystem::path d, bool create) const p /= d; if (create) { - boost::filesystem::create_directories (p); + dcp::filesystem::create_directories(p); } return p; @@ -758,7 +739,7 @@ Film::file (boost::filesystem::path f) const p /= _directory.get(); p /= f; - boost::filesystem::create_directories (p.parent_path ()); + dcp::filesystem::create_directories(p.parent_path()); return p; } @@ -1319,9 +1300,9 @@ Film::cpls () const vector out; auto const dir = directory().get(); - for (auto const& item: boost::filesystem::directory_iterator(dir)) { + for (auto const& item: dcp::filesystem::directory_iterator(dir)) { if ( - boost::filesystem::is_directory(item) && + dcp::filesystem::is_directory(item) && item.path().leaf() != "j2c" && item.path().leaf() != "video" && item.path().leaf() != "info" && item.path().leaf() != "analysis" ) { @@ -1743,15 +1724,15 @@ Film::should_be_enough_disk_space (double& required, double& available, bool& ca if (f) { f.close(); boost::system::error_code ec; - boost::filesystem::create_hard_link (test, test2, ec); + dcp::filesystem::create_hard_link(test, test2, ec); if (ec) { can_hard_link = false; } - boost::filesystem::remove (test); - boost::filesystem::remove (test2); + dcp::filesystem::remove(test); + dcp::filesystem::remove(test2); } - auto s = boost::filesystem::space (internal_video_asset_dir ()); + auto s = dcp::filesystem::space(internal_video_asset_dir()); required = double (required_disk_space ()) / 1073741824.0f; if (!can_hard_link) { required *= 2; @@ -2091,10 +2072,10 @@ Film::info_file_handle (DCPTimePeriod period, bool read) const InfoFileHandle::InfoFileHandle (boost::mutex& mutex, boost::filesystem::path path, bool read) : _lock (mutex) - , _file (path, read ? "rb" : (boost::filesystem::exists(path) ? "r+b" : "wb")) + , _file(path, read ? "rb" : (dcp::filesystem::exists(path) ? "r+b" : "wb")) { if (!_file) { - throw OpenFileError (path, errno, read ? OpenFileError::READ : (boost::filesystem::exists(path) ? OpenFileError::READ_WRITE : OpenFileError::WRITE)); + throw OpenFileError(path, errno, read ? OpenFileError::READ : (dcp::filesystem::exists(path) ? OpenFileError::READ_WRITE : OpenFileError::WRITE)); } } diff --git a/src/lib/find_missing.cc b/src/lib/find_missing.cc index 2234637b3..199ffcc19 100644 --- a/src/lib/find_missing.cc +++ b/src/lib/find_missing.cc @@ -22,7 +22,7 @@ #include "content.h" #include "find_missing.h" #include "util.h" -#include +#include using std::map; @@ -38,16 +38,16 @@ void search (Replacements& replacement_paths, boost::filesystem::path directory, int depth = 0) { boost::system::error_code ec; - for (auto candidate: boost::filesystem::directory_iterator(directory, ec)) { - if (boost::filesystem::is_regular_file(candidate.path())) { + for (auto candidate: dcp::filesystem::directory_iterator(directory, ec)) { + if (dcp::filesystem::is_regular_file(candidate.path())) { for (auto& replacement: replacement_paths) { for (auto& path: replacement.second) { - if (!boost::filesystem::exists(path) && path.filename() == candidate.path().filename()) { + if (!dcp::filesystem::exists(path) && path.filename() == candidate.path().filename()) { path = candidate.path(); } } } - } else if (boost::filesystem::is_directory(candidate.path()) && depth <= 2) { + } else if (dcp::filesystem::is_directory(candidate.path()) && depth <= 2) { search (replacement_paths, candidate, depth + 1); } } diff --git a/src/lib/font_config.cc b/src/lib/font_config.cc index 8804bd6d9..04f426cf9 100644 --- a/src/lib/font_config.cc +++ b/src/lib/font_config.cc @@ -24,6 +24,7 @@ #include "font.h" #include "font_config.h" #include "util.h" +#include #include #include #include @@ -48,7 +49,7 @@ FontConfig::~FontConfig() { for (auto file: _temp_files) { boost::system::error_code ec; - boost::filesystem::remove(file, ec); + dcp::filesystem::remove(file, ec); } } diff --git a/src/lib/hints.cc b/src/lib/hints.cc index a490c6b18..b4d94dbcc 100644 --- a/src/lib/hints.cc +++ b/src/lib/hints.cc @@ -38,6 +38,7 @@ #include "video_content.h" #include "writer.h" #include +#include #include #include #include @@ -259,7 +260,7 @@ Hints::check_big_font_files () for (auto j: i->text) { for (auto k: j->fonts()) { auto const p = k->file (); - if (p && boost::filesystem::file_size(p.get()) >= (MAX_FONT_FILE_SIZE - SIZE_SLACK)) { + if (p && dcp::filesystem::file_size(p.get()) >= (MAX_FONT_FILE_SIZE - SIZE_SLACK)) { big_font_files = true; } } @@ -310,7 +311,7 @@ bool Hints::check_loudness () { auto path = film()->audio_analysis_path(film()->playlist()); - if (!boost::filesystem::exists(path)) { + if (!dcp::filesystem::exists(path)) { return false; } @@ -352,7 +353,7 @@ static bool subtitle_mxf_too_big (shared_ptr asset) { - return asset && asset->file() && boost::filesystem::file_size(*asset->file()) >= (MAX_TEXT_MXF_SIZE - SIZE_SLACK); + return asset && asset->file() && dcp::filesystem::file_size(*asset->file()) >= (MAX_TEXT_MXF_SIZE - SIZE_SLACK); } @@ -452,7 +453,7 @@ try bool subs_mxf_too_big = false; auto dcp_dir = film->dir("hints") / dcpomatic::get_process_id(); - boost::filesystem::remove_all (dcp_dir); + dcp::filesystem::remove_all(dcp_dir); _writer->finish (film->dir("hints") / dcpomatic::get_process_id()); @@ -484,7 +485,7 @@ try subs_mxf_too_big = true; } } - boost::filesystem::remove_all (dcp_dir); + dcp::filesystem::remove_all(dcp_dir); emit (bind(boost::ref(Finished))); } diff --git a/src/lib/image_content.cc b/src/lib/image_content.cc index bb2de9307..1a92c944e 100644 --- a/src/lib/image_content.cc +++ b/src/lib/image_content.cc @@ -30,6 +30,7 @@ #include "util.h" #include "video_content.h" #include +#include #include #include @@ -49,7 +50,7 @@ ImageContent::ImageContent (boost::filesystem::path p) { video = make_shared(this); - if (boost::filesystem::is_regular_file (p) && valid_image_file (p)) { + if (dcp::filesystem::is_regular_file(p) && valid_image_file(p)) { add_path (p); } else { _path_to_scan = p; @@ -116,8 +117,8 @@ ImageContent::examine (shared_ptr film, shared_ptr job) job->sub (_("Scanning image files")); vector paths; int n = 0; - for (auto i: boost::filesystem::directory_iterator(*_path_to_scan)) { - if (boost::filesystem::is_regular_file(i.path()) && valid_image_file (i.path())) { + for (auto i: dcp::filesystem::directory_iterator(*_path_to_scan)) { + if (dcp::filesystem::is_regular_file(i.path()) && valid_image_file(i.path())) { paths.push_back (i.path()); } ++n; diff --git a/src/lib/image_examiner.cc b/src/lib/image_examiner.cc index 6e4dea7b7..ac2c95a08 100644 --- a/src/lib/image_examiner.cc +++ b/src/lib/image_examiner.cc @@ -31,6 +31,7 @@ #include "job.h" #include #include +#include #include #include @@ -50,7 +51,7 @@ ImageExaminer::ImageExaminer (shared_ptr film, shared_ptrpath(0); if (valid_j2k_file (path)) { - auto size = boost::filesystem::file_size (path); + auto size = dcp::filesystem::file_size(path); dcp::File f(path, "rb"); if (!f) { throw FileError ("Could not open file for reading", path); diff --git a/src/lib/job.cc b/src/lib/job.cc index 811e4c983..727456523 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -114,7 +114,7 @@ Job::run_wrapper () string m = String::compose (_("An error occurred whilst handling the file %1."), boost::filesystem::path (e.filename()).leaf()); try { - auto const s = boost::filesystem::space (e.filename()); + auto const s = dcp::filesystem::space(e.filename()); if (s.available < pow (1024, 3)) { m += N_("\n\n"); m += _("The drive that the film is stored on is low in disc space. Free some more space and try again."); @@ -169,7 +169,7 @@ Job::run_wrapper () String::compose (_("Could not open %1"), e.file().string()), String::compose ( _("DCP-o-matic could not open the file %1 (%2). Perhaps it does not exist or is in an unexpected format."), - boost::filesystem::absolute (e.file()).string(), + dcp::filesystem::absolute(e.file()).string(), e.what() ) ); @@ -184,7 +184,7 @@ Job::run_wrapper () String::compose (_("Could not open %1"), e.path1().string ()), String::compose ( _("DCP-o-matic could not open the file %1 (%2). Perhaps it does not exist or is in an unexpected format."), - boost::filesystem::absolute (e.path1()).string(), + dcp::filesystem::absolute(e.path1()).string(), e.what() ) ); diff --git a/src/lib/kdm_cli.cc b/src/lib/kdm_cli.cc index 3402fa71c..5ea808967 100644 --- a/src/lib/kdm_cli.cc +++ b/src/lib/kdm_cli.cc @@ -35,6 +35,7 @@ #include #include #include +#include #include @@ -435,7 +436,7 @@ optional kdm_cli (int argc, char* argv[], std::function out) try { - boost::filesystem::path output = boost::filesystem::current_path(); + boost::filesystem::path output = dcp::filesystem::current_path(); auto container_name_format = Config::instance()->kdm_container_name_format(); auto filename_format = Config::instance()->kdm_filename_format(); optional cinema_name; @@ -643,7 +644,7 @@ try } string const thing = argv[optind]; - if (boost::filesystem::is_directory(thing) && boost::filesystem::is_regular_file(boost::filesystem::path(thing) / "metadata.xml")) { + if (dcp::filesystem::is_directory(thing) && dcp::filesystem::is_regular_file(boost::filesystem::path(thing) / "metadata.xml")) { from_film ( screens, thing, @@ -661,7 +662,7 @@ try out ); } else { - if (boost::filesystem::is_regular_file(thing)) { + if (dcp::filesystem::is_regular_file(thing)) { dkdm = dcp::EncryptedKDM (dcp::file_to_string (thing)); } else { dkdm = find_dkdm (thing); diff --git a/src/lib/kdm_with_metadata.cc b/src/lib/kdm_with_metadata.cc index 5cbadc911..86573f43b 100644 --- a/src/lib/kdm_with_metadata.cc +++ b/src/lib/kdm_with_metadata.cc @@ -29,6 +29,7 @@ #include "util.h" #include "zipper.h" #include +#include #include "i18n.h" @@ -62,14 +63,14 @@ write_files ( return written; } - if (!boost::filesystem::exists (directory)) { - boost::filesystem::create_directories (directory); + if (!dcp::filesystem::exists(directory)) { + dcp::filesystem::create_directories(directory); } /* Write KDMs to the specified directory */ for (auto i: kdms) { - auto out = dcp::fix_long_path(directory / careful_string_filter(name_format.get(i->name_values(), ".xml"))); - if (!boost::filesystem::exists (out) || confirm_overwrite (out)) { + auto out = directory / careful_string_filter(name_format.get(i->name_values(), ".xml")); + if (!dcp::filesystem::exists(out) || confirm_overwrite(out)) { i->kdm_as_xml (out); ++written; } @@ -150,8 +151,8 @@ write_directories ( for (auto const& kdm: kdms) { auto path = directory; path /= container_name_format.get(kdm.front()->name_values(), "", "s"); - if (!boost::filesystem::exists (path) || confirm_overwrite (path)) { - boost::filesystem::create_directories (path); + if (!dcp::filesystem::exists(path) || confirm_overwrite(path)) { + dcp::filesystem::create_directories(path); write_files(kdm, path, filename_format, confirm_overwrite); written += kdm.size(); } @@ -176,10 +177,10 @@ write_zip_files ( for (auto const& kdm: kdms) { auto path = directory; path /= container_name_format.get(kdm.front()->name_values(), ".zip", "s"); - if (!boost::filesystem::exists (path) || confirm_overwrite (path)) { - if (boost::filesystem::exists (path)) { + if (!dcp::filesystem::exists(path) || confirm_overwrite(path)) { + if (dcp::filesystem::exists(path)) { /* Creating a new zip file over an existing one is an error */ - boost::filesystem::remove (path); + dcp::filesystem::remove(path); } make_zip_file(kdm, path, filename_format); written += kdm.size(); @@ -221,7 +222,7 @@ send_emails ( auto first = kdms_for_cinema.front(); auto zip_file = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path(); - boost::filesystem::create_directories (zip_file); + dcp::filesystem::create_directories(zip_file); zip_file /= container_name_format.get(first->name_values(), ".zip"); make_zip_file (kdms_for_cinema, zip_file, filename_format); @@ -278,13 +279,13 @@ send_emails ( try { email.send (config->mail_server(), config->mail_port(), config->mail_protocol(), config->mail_user(), config->mail_password()); } catch (...) { - boost::filesystem::remove (zip_file); + dcp::filesystem::remove(zip_file); log_details (email); throw; } log_details (email); - boost::filesystem::remove (zip_file); + dcp::filesystem::remove(zip_file); } } diff --git a/src/lib/map_cli.cc b/src/lib/map_cli.cc index 86f5057c0..368c35725 100644 --- a/src/lib/map_cli.cc +++ b/src/lib/map_cli.cc @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -150,7 +151,7 @@ map_cli(int argc, char* argv[], std::function out) return string{"Missing -o or --output"}; } - if (boost::filesystem::exists(*output_dir)) { + if (dcp::filesystem::exists(*output_dir)) { return String::compose("Output directory %1 already exists.", *output_dir); } @@ -159,7 +160,7 @@ map_cli(int argc, char* argv[], std::function out) } boost::system::error_code ec; - boost::filesystem::create_directory(*output_dir, ec); + dcp::filesystem::create_directory(*output_dir, ec); if (ec) { return String::compose("Could not create output directory %1: %2", *output_dir, ec.message()); } @@ -221,27 +222,27 @@ map_cli(int argc, char* argv[], std::function out) } if (rename) { - output_path /= String::compose("%1%2", (*iter)->id(), boost::filesystem::extension((*iter)->file().get())); + output_path /= String::compose("%1%2", (*iter)->id(), dcp::filesystem::extension((*iter)->file().get())); (*iter)->rename_file(output_path); } else { output_path /= (*iter)->file()->filename(); } - boost::filesystem::create_directories(output_path.parent_path()); + dcp::filesystem::create_directories(output_path.parent_path()); boost::system::error_code ec; if (hard_link) { - boost::filesystem::create_hard_link(input_path, output_path, ec); + dcp::filesystem::create_hard_link(input_path, output_path, ec); if (ec) { throw CopyError(String::compose("Could not hard-link asset %1: %2", input_path.string(), ec.message())); } } else if (soft_link) { - boost::filesystem::create_symlink(input_path, output_path, ec); + dcp::filesystem::create_symlink(input_path, output_path, ec); if (ec) { throw CopyError(String::compose("Could not soft-link asset %1: %2", input_path.string(), ec.message())); } } else { - boost::filesystem::copy_file(input_path, output_path, ec); + dcp::filesystem::copy_file(input_path, output_path, ec); if (ec) { throw CopyError(String::compose("Could not copy asset %1: %2", input_path.string(), ec.message())); } @@ -250,7 +251,7 @@ map_cli(int argc, char* argv[], std::function out) already_copied.push_back(asset_id); } else { boost::system::error_code ec; - boost::filesystem::remove_all(*output_dir, ec); + dcp::filesystem::remove_all(*output_dir, ec); throw CopyError(String::compose("Could not find required asset %1", asset_id)); } }; diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc index 7c0c9188a..9383f7c83 100644 --- a/src/lib/reel_writer.cc +++ b/src/lib/reel_writer.cc @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -136,15 +137,15 @@ ReelWriter::ReelWriter ( to change its contents (if only by changing the IDs); see #1126. */ - if (boost::filesystem::exists(asset) && boost::filesystem::hard_link_count(asset) > 1) { + if (dcp::filesystem::exists(asset) && dcp::filesystem::hard_link_count(asset) > 1) { if (job) { job->sub (_("Copying old video file")); copy_in_bits (asset, asset.string() + ".tmp", bind(&Job::set_progress, job.get(), _1, false)); } else { - boost::filesystem::copy_file (asset, asset.string() + ".tmp"); + dcp::filesystem::copy_file(asset, asset.string() + ".tmp"); } - boost::filesystem::remove (asset); - boost::filesystem::rename (asset.string() + ".tmp", asset); + dcp::filesystem::remove(asset); + dcp::filesystem::rename(asset.string() + ".tmp", asset); } @@ -294,8 +295,8 @@ ReelWriter::check_existing_picture_asset (boost::filesystem::path asset) } /* Offset of the last dcp::FrameInfo in the info file */ - int const n = (boost::filesystem::file_size(info_file->get().path()) / _info_size) - 1; - LOG_GENERAL ("The last FI is %1; info file is %2, info size %3", n, boost::filesystem::file_size(info_file->get().path()), _info_size); + int const n = (dcp::filesystem::file_size(info_file->get().path()) / _info_size) - 1; + LOG_GENERAL ("The last FI is %1; info file is %2, info size %3", n, dcp::filesystem::file_size(info_file->get().path()), _info_size); Frame first_nonexistent_frame; if (film()->three_d()) { @@ -401,9 +402,9 @@ ReelWriter::finish (boost::filesystem::path output_dcp) changing any video. */ boost::system::error_code ec; - boost::filesystem::remove (video_to, ec); + dcp::filesystem::remove(video_to, ec); - boost::filesystem::create_hard_link (video_from, video_to, ec); + dcp::filesystem::create_hard_link(video_from, video_to, ec); if (ec) { LOG_WARNING("Hard-link failed (%1); copying instead", error_details(ec)); auto job = _job.lock (); @@ -416,7 +417,7 @@ ReelWriter::finish (boost::filesystem::path output_dcp) throw FileError (e.what(), video_from); } } else { - boost::filesystem::copy_file (video_from, video_to, ec); + dcp::filesystem::copy_file(video_from, video_to, ec); if (ec) { LOG_ERROR("Failed to copy video file from %1 to %2 (%3)", video_from.string(), video_to.string(), error_details(ec)); throw FileError (ec.message(), video_from); @@ -434,7 +435,7 @@ ReelWriter::finish (boost::filesystem::path output_dcp) audio_to /= aaf; boost::system::error_code ec; - boost::filesystem::rename (film()->file(aaf), audio_to, ec); + dcp::filesystem::rename(film()->file(aaf), audio_to, ec); if (ec) { throw FileError ( String::compose(_("could not move audio asset into the DCP (%1)"), error_details(ec)), aaf @@ -451,7 +452,7 @@ ReelWriter::finish (boost::filesystem::path output_dcp) atmos_to /= aaf; boost::system::error_code ec; - boost::filesystem::rename (film()->file(aaf), atmos_to, ec); + dcp::filesystem::rename(film()->file(aaf), atmos_to, ec); if (ec) { throw FileError ( String::compose(_("could not move atmos asset into the DCP (%1)"), error_details(ec)), aaf @@ -489,7 +490,7 @@ maybe_add_text ( if (asset) { if (auto interop = dynamic_pointer_cast(asset)) { auto directory = output_dcp / interop->id (); - boost::filesystem::create_directories (directory); + dcp::filesystem::create_directories(directory); interop->write (directory / subtitle_asset_filename(asset, reel_index, reel_count, content_summary, ".xml")); reel_asset = make_shared ( interop, diff --git a/src/lib/scoped_temporary.cc b/src/lib/scoped_temporary.cc index 0ead7b165..fec938cb1 100644 --- a/src/lib/scoped_temporary.cc +++ b/src/lib/scoped_temporary.cc @@ -19,9 +19,10 @@ */ -#include "scoped_temporary.h" -#include "exceptions.h" #include "cross.h" +#include "exceptions.h" +#include "scoped_temporary.h" +#include /** Construct a ScopedTemporary. A temporary filename is decided but the file is not opened @@ -40,7 +41,7 @@ ScopedTemporary::~ScopedTemporary () _file->close(); } boost::system::error_code ec; - boost::filesystem::remove (_path, ec); + dcp::filesystem::remove(_path, ec); } diff --git a/src/lib/scp_uploader.cc b/src/lib/scp_uploader.cc index dbe82b67f..6c63a6c3e 100644 --- a/src/lib/scp_uploader.cc +++ b/src/lib/scp_uploader.cc @@ -26,6 +26,7 @@ #include "cross.h" #include "compose.hpp" #include +#include #include #include @@ -110,7 +111,7 @@ LIBDCP_ENABLE_WARNINGS void SCPUploader::upload_file (boost::filesystem::path from, boost::filesystem::path to, boost::uintmax_t& transferred, boost::uintmax_t total_size) { - auto to_do = boost::filesystem::file_size (from); + auto to_do = dcp::filesystem::file_size(from); /* Use generic_string so that we get forward-slashes in the path, even on Windows */ LIBDCP_DISABLE_WARNINGS ssh_scp_push_file (_scp, to.generic_string().c_str(), to_do, S_IRUSR | S_IWUSR); diff --git a/src/lib/spl.cc b/src/lib/spl.cc index 3e5e957ff..f49f11a7d 100644 --- a/src/lib/spl.cc +++ b/src/lib/spl.cc @@ -22,6 +22,7 @@ #include "content_store.h" #include "spl.h" #include +#include #include #include LIBDCP_DISABLE_WARNINGS @@ -42,7 +43,7 @@ SPL::read (boost::filesystem::path path, ContentStore* store) _spl.clear (); _missing = false; cxml::Document doc ("SPL"); - doc.read_file (path); + doc.read_file(dcp::filesystem::fix_long_path(path)); _id = doc.string_child("Id"); _name = doc.string_child("Name"); for (auto i: doc.node_children("Entry")) { diff --git a/src/lib/state.cc b/src/lib/state.cc index e22f9e0b9..f345d119e 100644 --- a/src/lib/state.cc +++ b/src/lib/state.cc @@ -22,6 +22,7 @@ #include "cross.h" #include "state.h" #include "util.h" +#include #include @@ -60,11 +61,9 @@ config_path_or_override (optional version) boost::filesystem::path State::read_path (string file) { - using namespace boost::filesystem; - for (auto i: config_versions) { auto full = config_path_or_override(i) / file; - if (exists(full)) { + if (dcp::filesystem::exists(full)) { return full; } } @@ -79,9 +78,9 @@ State::read_path (string file) boost::filesystem::path State::write_path (string file) { - boost::filesystem::path p = config_path_or_override(config_versions.front()); + auto p = config_path_or_override(config_versions.front()); boost::system::error_code ec; - boost::filesystem::create_directories (p, ec); + dcp::filesystem::create_directories(p, ec); p /= file; return p; } diff --git a/src/lib/subtitle_analysis.cc b/src/lib/subtitle_analysis.cc index 9b3ae86c0..ff1969a3a 100644 --- a/src/lib/subtitle_analysis.cc +++ b/src/lib/subtitle_analysis.cc @@ -22,6 +22,7 @@ #include "subtitle_analysis.h" #include "exceptions.h" #include +#include #include #include LIBDCP_DISABLE_WARNINGS @@ -42,7 +43,7 @@ SubtitleAnalysis::SubtitleAnalysis (boost::filesystem::path path) { cxml::Document f ("SubtitleAnalysis"); - f.read_file (path); + f.read_file(dcp::filesystem::fix_long_path(path)); if (f.optional_number_child("Version").get_value_or(1) < _current_state_version) { /* Too old. Throw an exception so that this analysis is re-run. */ diff --git a/src/lib/subtitle_encoder.cc b/src/lib/subtitle_encoder.cc index 4ce894afb..8b1d9a15b 100644 --- a/src/lib/subtitle_encoder.cc +++ b/src/lib/subtitle_encoder.cc @@ -24,6 +24,7 @@ #include "job.h" #include "player.h" #include "subtitle_encoder.h" +#include #include #include #include @@ -68,7 +69,7 @@ SubtitleEncoder::SubtitleEncoder (shared_ptr film, shared_ptr j for (int i = 0; i < files; ++i) { boost::filesystem::path filename = output; - if (boost::filesystem::is_directory(filename)) { + if (dcp::filesystem::is_directory(filename)) { if (files > 1) { /// TRANSLATORS: _reel%1 here is to be added to an export filename to indicate /// which reel it is. Preserve the %1; it will be replaced with the reel number. @@ -78,7 +79,7 @@ SubtitleEncoder::SubtitleEncoder (shared_ptr film, shared_ptr j } } - _assets.push_back (make_pair(shared_ptr(), boost::filesystem::change_extension(filename, extension))); + _assets.push_back(make_pair(shared_ptr(), dcp::filesystem::change_extension(filename, extension))); } for (auto i: film->reels()) { diff --git a/src/lib/types.cc b/src/lib/types.cc index 3ac3690c0..a87c354f3 100644 --- a/src/lib/types.cc +++ b/src/lib/types.cc @@ -23,6 +23,7 @@ #include "dcpomatic_assert.h" #include #include +#include #include #include #include @@ -71,7 +72,7 @@ CPLSummary::CPLSummary (boost::filesystem::path p) } boost::system::error_code ec; - auto last_write = boost::filesystem::last_write_time (p, ec); + auto last_write = dcp::filesystem::last_write_time(p, ec); last_write_time = ec ? 0 : last_write; } diff --git a/src/lib/util.cc b/src/lib/util.cc index 1ce288686..1a340cbce 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -448,7 +449,7 @@ LIBDCP_ENABLE_WARNINGS #ifdef DCPOMATIC_WINDOWS putenv ("PANGOCAIRO_BACKEND=fontconfig"); - if (boost::filesystem::exists(resources_path() / "fonts.conf")) { + if (dcp::filesystem::exists(resources_path() / "fonts.conf")) { /* The actual application after installation */ putenv(String::compose("FONTCONFIG_PATH=%1", resources_path().string()).c_str()); } else { @@ -562,7 +563,7 @@ digest_head_tail (vector files, boost::uintmax_t size) throw OpenFileError (files[i].string(), errno, OpenFileError::READ); } - boost::uintmax_t this_time = min (to_do, boost::filesystem::file_size (files[i])); + auto this_time = min(to_do, dcp::filesystem::file_size(files[i])); f.checked_read(p, this_time); p += this_time; to_do -= this_time; @@ -581,7 +582,7 @@ digest_head_tail (vector files, boost::uintmax_t size) throw OpenFileError (files[i].string(), errno, OpenFileError::READ); } - boost::uintmax_t this_time = min (to_do, boost::filesystem::file_size (files[i])); + auto this_time = min(to_do, dcp::filesystem::file_size(files[i])); f.seek(-this_time, SEEK_END); f.checked_read(p, this_time); p += this_time; @@ -598,7 +599,7 @@ digest_head_tail (vector files, boost::uintmax_t size) string simple_digest (vector paths) { - return digest_head_tail(paths, 1000000) + raw_convert(boost::filesystem::file_size(paths.front())); + return digest_head_tail(paths, 1000000) + raw_convert(dcp::filesystem::file_size(paths.front())); } @@ -965,7 +966,7 @@ copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, std::fun std::vector buffer(chunk); - boost::uintmax_t const total = boost::filesystem::file_size (from); + auto const total = dcp::filesystem::file_size(from); boost::uintmax_t remaining = total; while (remaining) { @@ -1037,7 +1038,7 @@ default_font_file () boost::filesystem::path liberation_normal; try { liberation_normal = resources_path() / "LiberationSans-Regular.ttf"; - if (!boost::filesystem::exists (liberation_normal)) { + if (!dcp::filesystem::exists(liberation_normal)) { /* Hack for unit tests */ liberation_normal = resources_path() / "fonts" / "LiberationSans-Regular.ttf"; } @@ -1045,10 +1046,10 @@ default_font_file () } - if (!boost::filesystem::exists(liberation_normal)) { + if (!dcp::filesystem::exists(liberation_normal)) { liberation_normal = "/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf"; } - if (!boost::filesystem::exists(liberation_normal)) { + if (!dcp::filesystem::exists(liberation_normal)) { liberation_normal = "/usr/share/fonts/liberation-sans/LiberationSans-Regular.ttf"; } @@ -1084,7 +1085,7 @@ error_details(boost::system::error_code ec) bool contains_assetmap(boost::filesystem::path dir) { - return boost::filesystem::is_regular_file(dir / "ASSETMAP") || boost::filesystem::is_regular_file(dir / "ASSETMAP.xml"); + return dcp::filesystem::is_regular_file(dir / "ASSETMAP") || dcp::filesystem::is_regular_file(dir / "ASSETMAP.xml"); } diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 1ccf7c759..6bc3da504 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -734,11 +734,11 @@ Writer::write_cover_sheet (boost::filesystem::path output_dcp) boost::uintmax_t size = 0; for ( - auto i = boost::filesystem::recursive_directory_iterator(output_dcp); - i != boost::filesystem::recursive_directory_iterator(); + auto i = dcp::filesystem::recursive_directory_iterator(output_dcp); + i != dcp::filesystem::recursive_directory_iterator(); ++i) { - if (boost::filesystem::is_regular_file (i->path())) { - size += boost::filesystem::file_size (i->path()); + if (dcp::filesystem::is_regular_file(i->path())) { + size += dcp::filesystem::file_size(i->path()); } } diff --git a/src/lib/zipper.cc b/src/lib/zipper.cc index d095a27bb..e37c8aa12 100644 --- a/src/lib/zipper.cc +++ b/src/lib/zipper.cc @@ -19,23 +19,24 @@ */ -#include "zipper.h" -#include "exceptions.h" #include "dcpomatic_assert.h" +#include "exceptions.h" +#include "zipper.h" +#include #include #include #include -using std::string; using std::runtime_error; using std::shared_ptr; +using std::string; Zipper::Zipper (boost::filesystem::path file) { int error; - _zip = zip_open (file.string().c_str(), ZIP_CREATE | ZIP_EXCL, &error); + _zip = zip_open(dcp::filesystem::fix_long_path(file).string().c_str(), ZIP_CREATE | ZIP_EXCL, &error); if (!_zip) { if (error == ZIP_ER_EXISTS) { throw FileError ("ZIP file already exists", file); diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 0ed65da8d..979672fb4 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -91,6 +91,7 @@ #include "lib/version.h" #include "lib/video_content.h" #include +#include #include #include LIBDCP_DISABLE_WARNINGS @@ -475,7 +476,7 @@ public: } catch (FileNotFoundError& e) { auto const dir = e.file().parent_path(); - if (boost::filesystem::exists(dir / "ASSETMAP") || boost::filesystem::exists(dir / "ASSETMAP.xml")) { + if (dcp::filesystem::exists(dir / "ASSETMAP") || dcp::filesystem::exists(dir / "ASSETMAP.xml")) { error_dialog ( this, _("Could not open this folder as a DCP-o-matic project."), _("It looks like you are trying to open a DCP. File -> Open is for loading DCP-o-matic projects, not DCPs. To import a DCP, create a new project with File -> New and then click the \"Add DCP...\" button.") @@ -803,11 +804,11 @@ private: /* Remove any existing DCP if the user agrees */ auto const dcp_dir = _film->dir (_film->dcp_name(), false); - if (boost::filesystem::exists(dcp_dir)) { + if (dcp::filesystem::exists(dcp_dir)) { if (!confirm_dialog (this, wxString::Format (_("Do you want to overwrite the existing DCP %s?"), std_to_wx(dcp_dir.string()).data()))) { return; } - boost::filesystem::remove_all (dcp_dir); + dcp::filesystem::remove_all(dcp_dir); } try { @@ -981,7 +982,7 @@ private: return; } - if (boost::filesystem::exists(dialog.path())) { + if (dcp::filesystem::exists(dialog.path())) { bool ok = confirm_dialog( this, wxString::Format(_("File %s already exists. Do you want to overwrite it?"), std_to_wx(dialog.path().string()).data()) @@ -1676,7 +1677,7 @@ private: signal_manager = new wxSignalManager (this); Bind (wxEVT_IDLE, boost::bind (&App::idle, this, _1)); - if (!_film_to_load.empty() && boost::filesystem::is_directory(_film_to_load)) { + if (!_film_to_load.empty() && dcp::filesystem::is_directory(_film_to_load)) { try { _frame->load_film (_film_to_load); } catch (exception& e) { diff --git a/src/tools/dcpomatic_batch.cc b/src/tools/dcpomatic_batch.cc index 24897dfba..dc092bf8c 100644 --- a/src/tools/dcpomatic_batch.cc +++ b/src/tools/dcpomatic_batch.cc @@ -37,6 +37,7 @@ #include "lib/transcode_job.h" #include "lib/util.h" #include "lib/version.h" +#include #include LIBDCP_DISABLE_WARNINGS #include @@ -129,7 +130,7 @@ public: if (filenames.GetCount() == 1) { /* Try to load a directory */ auto path = boost::filesystem::path(wx_to_std(filenames[0])); - if (boost::filesystem::is_directory(path)) { + if (dcp::filesystem::is_directory(path)) { _frame->start_job(wx_to_std(filenames[0])); return true; } @@ -479,7 +480,7 @@ class App : public wxApp shared_ptr film; for (auto i: films_to_load) { - if (boost::filesystem::is_directory(i)) { + if (dcp::filesystem::is_directory(i)) { try { film = make_shared(i); film->read_metadata (); diff --git a/src/tools/dcpomatic_cli.cc b/src/tools/dcpomatic_cli.cc index 3e1e13c51..96bf83086 100644 --- a/src/tools/dcpomatic_cli.cc +++ b/src/tools/dcpomatic_cli.cc @@ -39,6 +39,7 @@ #include "lib/util.h" #include "lib/version.h" #include "lib/video_content.h" +#include #include #include #include @@ -442,7 +443,7 @@ main (int argc, char* argv[]) for (auto i: film->content()) { auto paths = i->paths(); for (auto j: paths) { - if (!boost::filesystem::exists(j)) { + if (!dcp::filesystem::exists(j)) { cerr << argv[0] << ": content file " << j << " not found.\n"; exit (EXIT_FAILURE); } diff --git a/src/tools/dcpomatic_create.cc b/src/tools/dcpomatic_create.cc index 63889a597..5b5f4dba2 100644 --- a/src/tools/dcpomatic_create.cc +++ b/src/tools/dcpomatic_create.cc @@ -36,6 +36,7 @@ #include "lib/version.h" #include "lib/video_content.h" #include +#include #include #include #include @@ -94,10 +95,10 @@ main (int argc, char* argv[]) auto film = cc.make_film(); for (auto cli_content: cc.content) { - auto const can = boost::filesystem::canonical (cli_content.path); + auto const can = dcp::filesystem::canonical(cli_content.path); vector> film_content_list; - if (boost::filesystem::exists (can / "ASSETMAP") || (boost::filesystem::exists (can / "ASSETMAP.xml"))) { + if (dcp::filesystem::exists(can / "ASSETMAP") || (dcp::filesystem::exists(can / "ASSETMAP.xml"))) { auto dcp = make_shared(can); film_content_list.push_back (dcp); if (cli_content.kdm) { diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index 6628c2b3f..fbeac7640 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -53,6 +53,7 @@ #include #include #include +#include #include LIBDCP_DISABLE_WARNINGS #include @@ -312,7 +313,7 @@ private: bool confirm_overwrite (boost::filesystem::path path) { - if (boost::filesystem::is_directory(path)) { + if (dcp::filesystem::is_directory(path)) { return confirm_dialog ( this, wxString::Format(_("Folder %s already exists. Do you want to overwrite it?"), std_to_wx(path.string()).data()) diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc index c4f0e886c..88b0f839d 100644 --- a/src/tools/dcpomatic_player.cc +++ b/src/tools/dcpomatic_player.cc @@ -68,6 +68,7 @@ #include #include #include +#include #include #include #include @@ -169,7 +170,7 @@ public: if (filenames.GetCount() == 1) { /* Try to load a directory */ auto path = boost::filesystem::path(wx_to_std(filenames[0])); - if (boost::filesystem::is_directory(path)) { + if (dcp::filesystem::is_directory(path)) { _frame->load_dcp(wx_to_std(filenames[0])); return true; } @@ -1236,7 +1237,7 @@ private: LOG_DEBUG_PLAYER ("Failed to start play server (%1)", e.what()); } - if (!_dcp_to_load.empty() && boost::filesystem::is_directory (_dcp_to_load)) { + if (!_dcp_to_load.empty() && dcp::filesystem::is_directory(_dcp_to_load)) { try { _frame->load_dcp (_dcp_to_load); } catch (exception& e) { diff --git a/src/tools/dcpomatic_playlist.cc b/src/tools/dcpomatic_playlist.cc index cb153d6c1..e4ad3c658 100644 --- a/src/tools/dcpomatic_playlist.cc +++ b/src/tools/dcpomatic_playlist.cc @@ -32,6 +32,7 @@ #include "lib/film.h" #include "lib/spl.h" #include "lib/spl_entry.h" +#include #include LIBDCP_DISABLE_WARNINGS #include @@ -222,7 +223,7 @@ private: _list->DeleteAllItems (); _playlists.clear (); - for (auto i: boost::filesystem::directory_iterator(*path)) { + for (auto i: dcp::filesystem::directory_iterator(*path)) { auto spl = make_shared(); try { spl->read (i, _content_store); @@ -271,7 +272,7 @@ private: return; } - boost::filesystem::remove(*dir / (_playlists[*index]->id() + ".xml")); + dcp::filesystem::remove(*dir / (_playlists[*index]->id() + ".xml")); _list->DeleteItem(*index); _playlists.erase(_playlists.begin() + *index); diff --git a/src/wx/audio_dialog.cc b/src/wx/audio_dialog.cc index 88377b4e4..714bf78e4 100644 --- a/src/wx/audio_dialog.cc +++ b/src/wx/audio_dialog.cc @@ -30,6 +30,7 @@ #include "lib/film.h" #include "lib/job_manager.h" #include "lib/maths_util.h" +#include #include #include #include @@ -207,7 +208,7 @@ AudioDialog::try_to_load_analysis () auto check = _content.lock(); auto const path = film->audio_analysis_path (_playlist); - if (!boost::filesystem::exists (path)) { + if (!dcp::filesystem::exists(path)) { _plot->set_analysis (shared_ptr ()); _analysis.reset (); @@ -295,7 +296,7 @@ AudioDialog::analysis_finished () return; } - if (!boost::filesystem::exists (film->audio_analysis_path (_playlist))) { + if (!dcp::filesystem::exists(film->audio_analysis_path(_playlist))) { /* We analysed and still nothing showed up, so maybe it was cancelled or it failed. Give up. */ diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index fdb7947da..00ae80a4c 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -27,6 +27,7 @@ #include "static_text.h" #include "lib/constants.h" #include +#include #include @@ -576,7 +577,7 @@ CertificateChainEditor::import_private_key () if (d->ShowModal() == wxID_OK) { try { boost::filesystem::path p (wx_to_std (d->GetPath ())); - if (boost::filesystem::file_size (p) > 8192) { + if (dcp::filesystem::file_size(p) > 8192) { error_dialog ( this, wxString::Format (_("Could not read key file; file is too long (%s)"), std_to_wx (p.string ())) diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index fadcade31..56c1d0524 100644 --- a/src/wx/content_panel.cc +++ b/src/wx/content_panel.cc @@ -51,6 +51,7 @@ #include "lib/string_text_file_content.h" #include "lib/text_content.h" #include "lib/video_content.h" +#include #include LIBDCP_DISABLE_WARNINGS #include @@ -152,9 +153,9 @@ public: vector folders; for (size_t i = 0; i < filenames.GetCount(); ++i) { auto path = boost::filesystem::path(wx_to_std(filenames[i])); - if (boost::filesystem::is_regular_file(path)) { + if (dcp::filesystem::is_regular_file(path)) { files.push_back(path); - } else if (boost::filesystem::is_directory(path)) { + } else if (dcp::filesystem::is_directory(path)) { if (contains_assetmap(path)) { dcps.push_back(path); } else { diff --git a/src/wx/content_view.cc b/src/wx/content_view.cc index 73cc9e68b..b9fe7ce00 100644 --- a/src/wx/content_view.cc +++ b/src/wx/content_view.cc @@ -30,6 +30,7 @@ #include "lib/job_manager.h" #include "lib/util.h" #include +#include #include #include #include @@ -81,7 +82,7 @@ ContentView::update () DeleteAllItems (); _content.clear (); auto dir = Config::instance()->player_content_directory(); - if (!dir || !boost::filesystem::is_directory(*dir)) { + if (!dir || !dcp::filesystem::is_directory(*dir)) { dir = home_directory (); } diff --git a/src/wx/film_name_location_dialog.cc b/src/wx/film_name_location_dialog.cc index 5c6f97f99..05ffa7a68 100644 --- a/src/wx/film_name_location_dialog.cc +++ b/src/wx/film_name_location_dialog.cc @@ -150,7 +150,7 @@ FilmNameLocationDialog::check_path () )) { return false; } - } else if (boost::filesystem::is_regular_file(path())) { + } else if (filesystem::is_regular_file(path())) { error_dialog ( this, String::compose (wx_to_std(_("%1 already exists as a file, so you cannot use it for a film.")), path().c_str()) diff --git a/src/wx/fonts_dialog.cc b/src/wx/fonts_dialog.cc index c59607e8f..a035a5ffc 100644 --- a/src/wx/fonts_dialog.cc +++ b/src/wx/fonts_dialog.cc @@ -27,6 +27,7 @@ #include "lib/font.h" #include "lib/scope_guard.h" #include "lib/text_content.h" +#include #include LIBDCP_DISABLE_WARNINGS #include @@ -174,7 +175,7 @@ FontsDialog::set_from_file_clicked () */ wxString default_dir = ""; #ifdef DCPOMATIC_LINUX - if (boost::filesystem::exists ("/usr/share/fonts/truetype")) { + if (dcp::filesystem::exists("/usr/share/fonts/truetype")) { default_dir = "/usr/share/fonts/truetype"; } else { default_dir = "/usr/share/fonts"; diff --git a/src/wx/full_config_dialog.cc b/src/wx/full_config_dialog.cc index c61c75ece..175d78730 100644 --- a/src/wx/full_config_dialog.cc +++ b/src/wx/full_config_dialog.cc @@ -57,6 +57,7 @@ #include "lib/util.h" #include #include +#include #include #include LIBDCP_DISABLE_WARNINGS @@ -186,7 +187,7 @@ private: ); if (dialog.ShowModal() == wxID_OK) { - boost::filesystem::copy_file(Config::instance()->cinemas_file(), wx_to_std(dialog.GetPath()), boost::filesystem::copy_option::overwrite_if_exists); + dcp::filesystem::copy_file(Config::instance()->cinemas_file(), wx_to_std(dialog.GetPath()), boost::filesystem::copy_option::overwrite_if_exists); } } @@ -220,7 +221,7 @@ private: return; } bool copy_and_link = true; - if (boost::filesystem::exists(new_file)) { + if (dcp::filesystem::exists(new_file)) { ConfigMoveDialog dialog(_panel, new_file); if (dialog.ShowModal() == wxID_OK) { copy_and_link = false; diff --git a/src/wx/kdm_cpl_panel.cc b/src/wx/kdm_cpl_panel.cc index 1ddaa90cf..2a307c60c 100644 --- a/src/wx/kdm_cpl_panel.cc +++ b/src/wx/kdm_cpl_panel.cc @@ -112,7 +112,7 @@ KDMCPLPanel::cpl_browse_clicked () try { /* XXX: hack alert */ cxml::Document cpl_document ("CompositionPlaylist"); - cpl_document.read_file (cpl_file); + cpl_document.read_file(dcp::filesystem::fix_long_path(cpl_file)); bool encrypted = false; for (auto i: cpl_document.node_children("ReelList")) { diff --git a/src/wx/system_font_dialog.cc b/src/wx/system_font_dialog.cc index 1681dd1e3..84285de12 100644 --- a/src/wx/system_font_dialog.cc +++ b/src/wx/system_font_dialog.cc @@ -21,6 +21,7 @@ #include "system_font_dialog.h" #include "wx_util.h" +#include #include LIBDCP_DISABLE_WARNINGS #include @@ -43,7 +44,7 @@ SystemFontDialog::SystemFontDialog (wxWindow* parent) fonts = boost::filesystem::path (windir) / "Fonts"; } - for (auto i: boost::filesystem::directory_iterator (fonts)) { + for (auto i: dcp::filesystem::directory_iterator(fonts)) { auto ext = i.path().extension().string(); transform (ext.begin(), ext.end(), ext.begin(), ::tolower); diff --git a/src/wx/text_panel.cc b/src/wx/text_panel.cc index ff4e26a57..3b7973e30 100644 --- a/src/wx/text_panel.cc +++ b/src/wx/text_panel.cc @@ -47,6 +47,7 @@ #include "lib/string_text_file_decoder.h" #include "lib/subtitle_analysis.h" #include "lib/text_content.h" +#include #include LIBDCP_DISABLE_WARNINGS #include @@ -827,7 +828,7 @@ TextPanel::try_to_load_analysis () auto const path = _parent->film()->subtitle_analysis_path(content); - if (!boost::filesystem::exists(path)) { + if (!dcp::filesystem::exists(path)) { for (auto i: JobManager::instance()->get()) { if (dynamic_pointer_cast(i) && !i->finished()) { i->cancel (); @@ -898,7 +899,7 @@ TextPanel::analysis_finished(Job::Result result) return; } - if (!boost::filesystem::exists(_parent->film()->subtitle_analysis_path(content))) { + if (!dcp::filesystem::exists(_parent->film()->subtitle_analysis_path(content))) { /* We analysed and still nothing showed up, so maybe it failed. Give up. */ error_dialog (_parent->window(), _("Could not analyse subtitles.")); clear_outline_subtitles (); diff --git a/test/test.cc b/test/test.cc index 630026120..9b08dfb4e 100644 --- a/test/test.cc +++ b/test/test.cc @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -107,7 +108,7 @@ TestPaths::TestPaths::private_data () boost::filesystem::path TestPaths::xsd () { - return boost::filesystem::canonical(boost::filesystem::path("..") / boost::filesystem::path("libdcp") / boost::filesystem::path("xsd")); + return boost::filesystem::current_path().parent_path() / "libdcp" / "xsd"; } diff --git a/test/zipper_test.cc b/test/zipper_test.cc index 1b8c386f4..37e6176f0 100644 --- a/test/zipper_test.cc +++ b/test/zipper_test.cc @@ -28,6 +28,7 @@ #include "lib/exceptions.h" #include "lib/zipper.h" #include "test.h" +#include #include #include #include @@ -44,6 +45,11 @@ BOOST_AUTO_TEST_CASE (zipper_test1) zipper.add ("bar.txt", "xxxxxxCCCCbbbbbbb1"); zipper.close (); + /* Make sure we aren't in a UNC current working directory otherwise the use of cmd.exe + * in system() below will fail. + */ + boost::filesystem::current_path(dcp::filesystem::unfix_long_path(boost::filesystem::current_path())); + boost::filesystem::remove_all ("build/test/zipper_test1", ec); #ifdef DCPOMATIC_WINDOWS /* unzip on windows crashes every so often (with a return code -1073740940, for some reason) -- cgit v1.2.3