Use dcp::filesystem to wrap filesystem calls and fix_long_path
authorCarl Hetherington <cth@carlh.net>
Fri, 6 Oct 2023 00:37:16 +0000 (02:37 +0200)
committerCarl Hetherington <cth@carlh.net>
Mon, 9 Oct 2023 21:38:28 +0000 (23:38 +0200)
anything that is passed to read_file() from libcxml.

This should fix #2623 and other similar problems.

49 files changed:
src/lib/analytics.cc
src/lib/audio_analysis.cc
src/lib/config.cc
src/lib/content.cc
src/lib/content_factory.cc
src/lib/cross_linux.cc
src/lib/ffmpeg_encoder.cc
src/lib/file_group.cc
src/lib/file_log.cc
src/lib/film.cc
src/lib/find_missing.cc
src/lib/font_config.cc
src/lib/hints.cc
src/lib/image_content.cc
src/lib/image_examiner.cc
src/lib/job.cc
src/lib/kdm_cli.cc
src/lib/kdm_with_metadata.cc
src/lib/map_cli.cc
src/lib/reel_writer.cc
src/lib/scoped_temporary.cc
src/lib/scp_uploader.cc
src/lib/spl.cc
src/lib/state.cc
src/lib/subtitle_analysis.cc
src/lib/subtitle_encoder.cc
src/lib/types.cc
src/lib/util.cc
src/lib/writer.cc
src/lib/zipper.cc
src/tools/dcpomatic.cc
src/tools/dcpomatic_batch.cc
src/tools/dcpomatic_cli.cc
src/tools/dcpomatic_create.cc
src/tools/dcpomatic_kdm.cc
src/tools/dcpomatic_player.cc
src/tools/dcpomatic_playlist.cc
src/wx/audio_dialog.cc
src/wx/config_dialog.cc
src/wx/content_panel.cc
src/wx/content_view.cc
src/wx/film_name_location_dialog.cc
src/wx/fonts_dialog.cc
src/wx/full_config_dialog.cc
src/wx/kdm_cpl_panel.cc
src/wx/system_font_dialog.cc
src/wx/text_panel.cc
test/test.cc
test/zipper_test.cc

index 75146cb45313a60211339197bd72a1c2df119c0c..836051fe59616756482acf6003ba4539226e90a9 100644 (file)
@@ -22,6 +22,7 @@
 #include "analytics.h"
 #include "compose.hpp"
 #include "exceptions.h"
+#include <dcp/filesystem.h>
 #include <dcp/raw_convert.h>
 #include <dcp/warnings.h>
 #include <libcxml/cxml.h>
@@ -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<int>("SuccessfulDCPEncodes");
 } catch (...) {
        /* Never mind */
index 6f1bb2375613f851116eb66d096c9fc147296d99..b8c2e072db8d6d94a364dd0a1054f0c126696703 100644 (file)
@@ -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<int>("Version").get_value_or(1) < _current_state_version) {
                /* Too old.  Throw an exception so that this analysis is re-run. */
index fdce7510995947886af1d80a030c28594db65fbd..063fbcab9b16f922151485045c44ec88a6f5e17b 100644 (file)
@@ -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<int> ("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<shared_ptr<T>> 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<boost::filesystem::path> 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<boost::filesystem::path>& 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<boost::filesystem::path>& 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<const Film> film, string name) const
 list<string>
 Config::templates () const
 {
-       if (!boost::filesystem::exists(read_path("templates"))) {
+       if (!dcp::filesystem::exists(read_path("templates"))) {
                return {};
        }
 
        list<string> 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()));
        }
 
index 97edc7c892c33612263ae14b33e403d3a0b1bd11..6324050ec69a22f056cc3bedb4c1c7ae2ff002f0 100644 (file)
@@ -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<const Film>, shared_ptr<Job> 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<boost::filesystem::path> 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;
                }
index b23a088b4d0cb0d4ac51def352a72ac0b32cad46..e1278c3b475d41f3711d69b81501d17a909990fc 100644 (file)
@@ -40,6 +40,7 @@
 #include "log.h"
 #include "compose.hpp"
 #include <libcxml/cxml.h>
+#include <dcp/filesystem.h>
 #include <dcp/smpte_subtitle_asset.h>
 #include <boost/algorithm/string.hpp>
 
@@ -111,11 +112,11 @@ content_factory (boost::filesystem::path path)
 {
        vector<shared_ptr<Content>> 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<ImageContent>(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<FFmpegContent>(i.path()));
                        }
                }
@@ -172,7 +173,7 @@ content_factory (boost::filesystem::path path)
                        single = make_shared<StringTextFileContent>(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 ();
                        }
index 0a12d7ccadc42e28f0edda0fed7fe13282d03e7e..015158aa8b1a7eee4f15e43c46d094300dc3f657 100644 (file)
@@ -26,6 +26,7 @@
 #include "dcpomatic_log.h"
 #include "exceptions.h"
 #include "log.h"
+#include <dcp/filesystem.h>
 #include <dcp/raw_convert.h>
 #include <dcp/warnings.h>
 #include <glib.h>
@@ -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;
        }
 
index 00ad75526bb9e6a231c72032d7ade3badab685de..60241b23319f3816b265a5b3beacebb07d4ee62b 100644 (file)
@@ -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
index f4d50028ecdc1037ae1547818e30248992fd64d4..228faa74ddd6818cf5ae9fe21287335c572117f1 100644 (file)
@@ -29,6 +29,7 @@
 #include "dcpomatic_assert.h"
 #include "exceptions.h"
 #include "file_group.h"
+#include <dcp/filesystem.h>
 #include <sndfile.h>
 #include <cstdio>
 
@@ -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;
index adb06b7f04fb71f4f6e986cdd930ffdc1ba3b602..5265e2a9dddfd8704e5f4e649809a4f1c3b6a051 100644 (file)
@@ -23,6 +23,7 @@
 #include "cross.h"
 #include "config.h"
 #include <dcp/file.h>
+#include <dcp/filesystem.h>
 #include <cstdio>
 #include <iostream>
 #include <cerrno>
@@ -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<uintmax_t>(-1)) {
                return "";
        }
index 803dbb73204ad7a3b223ca183273d33482066d30..a6d10b9bf3c9060b7e33ad08178a847f24e281ce 100644 (file)
@@ -63,6 +63,7 @@
 #include <dcp/certificate_chain.h>
 #include <dcp/cpl.h>
 #include <dcp/decrypted_kdm.h>
+#include <dcp/filesystem.h>
 #include <dcp/local_time.h>
 #include <dcp/raw_convert.h>
 #include <dcp/reel_asset.h>
@@ -205,27 +206,7 @@ Film::Film (optional<boost::filesystem::path> 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<xmlpp::Document> doc = metadata (false);
        metadata(false)->write_to_file_formatted(path.string());
 }
@@ -520,19 +501,19 @@ list<string>
 Film::read_metadata (optional<boost::filesystem::path> 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<int> ("Version");
        if (_state_version > current_state_version) {
@@ -540,9 +521,9 @@ Film::read_metadata (optional<boost::filesystem::path> 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<CPLSummary> 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));
        }
 }
 
index 2234637b3150aaa334d245040b172d3caa02adba..199ffcc19ccab35ad4b4e381a507be6160a071c5 100644 (file)
@@ -22,7 +22,7 @@
 #include "content.h"
 #include "find_missing.h"
 #include "util.h"
-#include <boost/filesystem.hpp>
+#include <dcp/filesystem.h>
 
 
 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);
                }
        }
index 8804bd6d96522b8aa2baf0a8b9e341405393766e..04f426cf97abc8eb4a5044861713ba95a1d26ae2 100644 (file)
@@ -24,6 +24,7 @@
 #include "font.h"
 #include "font_config.h"
 #include "util.h"
+#include <dcp/filesystem.h>
 #include <fontconfig/fontconfig.h>
 #include <boost/filesystem.hpp>
 #include <boost/optional.hpp>
@@ -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);
        }
 }
 
index a490c6b18db6dd1f40f3c051df338535aa8413ae..b4d94dbcc3d03ab4ab06de1045c94cdd2b7f153f 100644 (file)
@@ -38,6 +38,7 @@
 #include "video_content.h"
 #include "writer.h"
 #include <dcp/cpl.h>
+#include <dcp/filesystem.h>
 #include <dcp/raw_convert.h>
 #include <dcp/reel.h>
 #include <dcp/reel_closed_caption_asset.h>
@@ -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<dcp::SubtitleAsset> 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)));
 }
index bb2de93073e42cc8b88a040a34c9163bd3e7de74..1a92c944ed8047cdceb50f7f43b46e894923a323 100644 (file)
@@ -30,6 +30,7 @@
 #include "util.h"
 #include "video_content.h"
 #include <libcxml/cxml.h>
+#include <dcp/filesystem.h>
 #include <libxml++/libxml++.h>
 #include <iostream>
 
@@ -49,7 +50,7 @@ ImageContent::ImageContent (boost::filesystem::path p)
 {
        video = make_shared<VideoContent>(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<const Film> film, shared_ptr<Job> job)
                job->sub (_("Scanning image files"));
                vector<boost::filesystem::path> 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;
index 6e4dea7b7da6f1ddc104341f5a8c5bf415475578..ac2c95a08a1d71f12d0333fb56db2c9901721bd0 100644 (file)
@@ -31,6 +31,7 @@
 #include "job.h"
 #include <dcp/openjpeg_image.h>
 #include <dcp/exceptions.h>
+#include <dcp/filesystem.h>
 #include <dcp/j2k_transcode.h>
 #include <iostream>
 
@@ -50,7 +51,7 @@ ImageExaminer::ImageExaminer (shared_ptr<const Film> film, shared_ptr<const Imag
 {
        auto path = content->path(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);
index 811e4c983672f27fb4a996280aacb86d3916ada9..727456523ca39e7e58f1045fa4df1aea3095d291 100644 (file)
@@ -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()
                                        )
                                );
index 3402fa71cf0cbc061bb5f5c6398e725af93af925..5ea8089674c051377cd045afaf6cc8a95f6d7b12 100644 (file)
@@ -35,6 +35,7 @@
 #include <dcp/certificate.h>
 #include <dcp/decrypted_kdm.h>
 #include <dcp/encrypted_kdm.h>
+#include <dcp/filesystem.h>
 #include <getopt.h>
 
 
@@ -435,7 +436,7 @@ optional<string>
 kdm_cli (int argc, char* argv[], std::function<void (string)> 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<string> 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);
index 5cbadc911a0dfba290dec7661f575688ad68e0c5..86573f43be903bd4266929e8bcc1378408b71459 100644 (file)
@@ -29,6 +29,7 @@
 #include "util.h"
 #include "zipper.h"
 #include <dcp/file.h>
+#include <dcp/filesystem.h>
 
 #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);
        }
 }
index 86f5057c08792a7f58449b6c34bd7c8bcfabba78..368c3572554a6df81db67f5acbeef96d93b8b974 100644 (file)
@@ -25,6 +25,7 @@
 #include <dcp/cpl.h>
 #include <dcp/dcp.h>
 #include <dcp/interop_subtitle_asset.h>
+#include <dcp/filesystem.h>
 #include <dcp/font_asset.h>
 #include <dcp/mono_picture_asset.h>
 #include <dcp/reel.h>
@@ -150,7 +151,7 @@ map_cli(int argc, char* argv[], std::function<void (string)> 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<void (string)> 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<void (string)> 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<void (string)> 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));
                }
        };
index 7c0c9188acca116074081c9b8e1d92004aeca589..9383f7c838a551ca8545e602776b4c985da1b7f3 100644 (file)
@@ -38,6 +38,7 @@
 #include <dcp/certificate_chain.h>
 #include <dcp/cpl.h>
 #include <dcp/dcp.h>
+#include <dcp/filesystem.h>
 #include <dcp/interop_subtitle_asset.h>
 #include <dcp/mono_picture_asset.h>
 #include <dcp/raw_convert.h>
@@ -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<dcp::InteropSubtitleAsset>(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> (
                                interop,
index 0ead7b1655d5445244aa103f67dcc597f160e035..fec938cb136ef2e3c75c5405f1736d73f44117c0 100644 (file)
 */
 
 
-#include "scoped_temporary.h"
-#include "exceptions.h"
 #include "cross.h"
+#include "exceptions.h"
+#include "scoped_temporary.h"
+#include <dcp/filesystem.h>
 
 
 /** 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);
 }
 
 
index dbe82b67f5987bd100474a8706e0b58d7ac17a37..6c63a6c3e881ac698c925a79b93a9cfe3d2bf999 100644 (file)
@@ -26,6 +26,7 @@
 #include "cross.h"
 #include "compose.hpp"
 #include <dcp/file.h>
+#include <dcp/filesystem.h>
 #include <dcp/warnings.h>
 #include <sys/stat.h>
 
@@ -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);
index 3e5e957ff457792257e37c243add266e2feb4524..f49f11a7d26ac15cb8b1429b6bd64b36ee3618ac 100644 (file)
@@ -22,6 +22,7 @@
 #include "content_store.h"
 #include "spl.h"
 #include <libcxml/cxml.h>
+#include <dcp/filesystem.h>
 #include <dcp/raw_convert.h>
 #include <dcp/warnings.h>
 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")) {
index e22f9e0b98bd71d37f4e6947d1563b1b6afd01c2..f345d119e1515f4d7a0aaa72e53486d1a1338e16 100644 (file)
@@ -22,6 +22,7 @@
 #include "cross.h"
 #include "state.h"
 #include "util.h"
+#include <dcp/filesystem.h>
 #include <glib.h>
 
 
@@ -60,11 +61,9 @@ config_path_or_override (optional<string> 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;
 }
index 9b3ae86c065656ad71394e0b01575ed30f2af4e1..ff1969a3a37c227cd32fde4a2dc793760648908a 100644 (file)
@@ -22,6 +22,7 @@
 #include "subtitle_analysis.h"
 #include "exceptions.h"
 #include <libcxml/cxml.h>
+#include <dcp/filesystem.h>
 #include <dcp/raw_convert.h>
 #include <dcp/warnings.h>
 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<int>("Version").get_value_or(1) < _current_state_version) {
                /* Too old.  Throw an exception so that this analysis is re-run. */
index 4ce894afb6364849f61cac057e9c3e03b75b0446..8b1d9a15ba7b5f9ca1d1d60d5da531f1f5580c8d 100644 (file)
@@ -24,6 +24,7 @@
 #include "job.h"
 #include "player.h"
 #include "subtitle_encoder.h"
+#include <dcp/filesystem.h>
 #include <dcp/interop_subtitle_asset.h>
 #include <dcp/raw_convert.h>
 #include <dcp/smpte_subtitle_asset.h>
@@ -68,7 +69,7 @@ SubtitleEncoder::SubtitleEncoder (shared_ptr<const Film> film, shared_ptr<Job> 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<const Film> film, shared_ptr<Job> j
                        }
                }
 
-               _assets.push_back (make_pair(shared_ptr<dcp::SubtitleAsset>(), boost::filesystem::change_extension(filename, extension)));
+               _assets.push_back(make_pair(shared_ptr<dcp::SubtitleAsset>(), dcp::filesystem::change_extension(filename, extension)));
        }
 
        for (auto i: film->reels()) {
index 3ac3690c0bd8dfccb567b67ae693a389d63e6d71..a87c354f31faa2d99a81448cae96f2e05fdc63c6 100644 (file)
@@ -23,6 +23,7 @@
 #include "dcpomatic_assert.h"
 #include <dcp/cpl.h>
 #include <dcp/dcp.h>
+#include <dcp/filesystem.h>
 #include <dcp/raw_convert.h>
 #include <dcp/reel_asset.h>
 #include <dcp/reel_file_asset.h>
@@ -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;
 }
 
index 1ce288686faec17ca20cf47a55a0b6fd2396bfc6..1a340cbcee16358402c1ea24d334e87e83965d84 100644 (file)
@@ -55,6 +55,7 @@
 #include <dcp/atmos_asset.h>
 #include <dcp/decrypted_kdm.h>
 #include <dcp/file.h>
+#include <dcp/filesystem.h>
 #include <dcp/locale_convert.h>
 #include <dcp/picture_asset.h>
 #include <dcp/raw_convert.h>
@@ -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<boost::filesystem::path> 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<boost::filesystem::path> 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<boost::filesystem::path> files, boost::uintmax_t size)
 string
 simple_digest (vector<boost::filesystem::path> paths)
 {
-       return digest_head_tail(paths, 1000000) + raw_convert<string>(boost::filesystem::file_size(paths.front()));
+       return digest_head_tail(paths, 1000000) + raw_convert<string>(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<uint8_t> 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");
 }
 
 
index 1ccf7c7596fd2aa7b15f9ff4559d2fa38c481146..6bc3da504e0e786643a9f5835123cf8da077f366 100644 (file)
@@ -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());
                }
        }
 
index d095a27bb6d74d24dd65110393086569d85330e8..e37c8aa123779f2a8da4fb0c9e5311886c00f836 100644 (file)
 */
 
 
-#include "zipper.h"
-#include "exceptions.h"
 #include "dcpomatic_assert.h"
+#include "exceptions.h"
+#include "zipper.h"
+#include <dcp/filesystem.h>
 #include <zip.h>
 #include <boost/filesystem.hpp>
 #include <stdexcept>
 
 
-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);
index 0ed65da8d82291721eac8a2b50355554cf63d9ba..979672fb4274e4ce110b08aad0189e993f168549 100644 (file)
@@ -91,6 +91,7 @@
 #include "lib/version.h"
 #include "lib/video_content.h"
 #include <dcp/exceptions.h>
+#include <dcp/filesystem.h>
 #include <dcp/raw_convert.h>
 #include <dcp/warnings.h>
 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) {
index 24897dfba1aaa993f8819a6fc9a7b0b8a018320e..dc092bf8ca1c06976a769cbc128daf22a6e0fcc6 100644 (file)
@@ -37,6 +37,7 @@
 #include "lib/transcode_job.h"
 #include "lib/util.h"
 #include "lib/version.h"
+#include <dcp/filesystem.h>
 #include <dcp/warnings.h>
 LIBDCP_DISABLE_WARNINGS
 #include <wx/aboutdlg.h>
@@ -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> film;
                for (auto i: films_to_load) {
-                       if (boost::filesystem::is_directory(i)) {
+                       if (dcp::filesystem::is_directory(i)) {
                                try {
                                        film = make_shared<Film>(i);
                                        film->read_metadata ();
index 3e1e13c515f84a1ce60e4938833e44541fbb9923..96bf830863f2b53266a34176357c8d29f97237fe 100644 (file)
@@ -39,6 +39,7 @@
 #include "lib/util.h"
 #include "lib/version.h"
 #include "lib/video_content.h"
+#include <dcp/filesystem.h>
 #include <dcp/version.h>
 #include <getopt.h>
 #include <iostream>
@@ -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);
                        }
index 63889a5977f7f9ff6bccdb4662b3926cfc031d2b..5b5f4dba2455f48739679a9f62a06d80ea3ada26 100644 (file)
@@ -36,6 +36,7 @@
 #include "lib/version.h"
 #include "lib/video_content.h"
 #include <dcp/exceptions.h>
+#include <dcp/filesystem.h>
 #include <libxml++/libxml++.h>
 #include <boost/filesystem.hpp>
 #include <getopt.h>
@@ -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<shared_ptr<Content>> 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<DCPContent>(can);
                                film_content_list.push_back (dcp);
                                if (cli_content.kdm) {
index 6628c2b3f6734def9a9908fe6de7e9a0da2254ab..fbeac764057ce93b48324ee95afbcb14cb9f4f90 100644 (file)
@@ -53,6 +53,7 @@
 #include <dcp/encrypted_kdm.h>
 #include <dcp/decrypted_kdm.h>
 #include <dcp/exceptions.h>
+#include <dcp/filesystem.h>
 #include <dcp/warnings.h>
 LIBDCP_DISABLE_WARNINGS
 #include <wx/dnd.h>
@@ -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())
index c4f0e886c3ff43f15a4d43aea7159bd24039e229..88b0f839df0e540069bedfc00b9dc9f5d1797f6c 100644 (file)
@@ -68,6 +68,7 @@
 #include <dcp/cpl.h>
 #include <dcp/dcp.h>
 #include <dcp/exceptions.h>
+#include <dcp/filesystem.h>
 #include <dcp/raw_convert.h>
 #include <dcp/search.h>
 #include <dcp/warnings.h>
@@ -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) {
index cb153d6c13077686c7fa8f820ac3f78d4a75f3c8..e4ad3c6585cf3776dd3e10732537ab630b112640 100644 (file)
@@ -32,6 +32,7 @@
 #include "lib/film.h"
 #include "lib/spl.h"
 #include "lib/spl_entry.h"
+#include <dcp/filesystem.h>
 #include <dcp/warnings.h>
 LIBDCP_DISABLE_WARNINGS
 #include <wx/imaglist.h>
@@ -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<SignalSPL>();
                        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);
 
index 88377b4e48912656f7e01889424f21976f4c77d6..714bf78e4e6c5c35b9e552dcf144ebb45b75f7e5 100644 (file)
@@ -30,6 +30,7 @@
 #include "lib/film.h"
 #include "lib/job_manager.h"
 #include "lib/maths_util.h"
+#include <dcp/filesystem.h>
 #include <libxml++/libxml++.h>
 #include <boost/filesystem.hpp>
 #include <iostream>
@@ -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<AudioAnalysis> ());
                _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.
                */
index fdb7947dab6e81d04abaa950c87b1326857e4438..00ae80a4c8f1f30079efa58d555ced06cb7cb803 100644 (file)
@@ -27,6 +27,7 @@
 #include "static_text.h"
 #include "lib/constants.h"
 #include <dcp/file.h>
+#include <dcp/filesystem.h>
 #include <dcp/raw_convert.h>
 
 
@@ -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 ()))
index fadcade313494df9da690f14d01835d9766a18e5..56c1d0524bd4a2053eaea192be18221e7935daaf 100644 (file)
@@ -51,6 +51,7 @@
 #include "lib/string_text_file_content.h"
 #include "lib/text_content.h"
 #include "lib/video_content.h"
+#include <dcp/filesystem.h>
 #include <dcp/warnings.h>
 LIBDCP_DISABLE_WARNINGS
 #include <wx/display.h>
@@ -152,9 +153,9 @@ public:
                vector<boost::filesystem::path> 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 {
index 73cc9e68bcee4dde0d88698a4192ff97d4cdfc92..b9fe7ce005a8dde13de020dffa0920317e96d84f 100644 (file)
@@ -30,6 +30,7 @@
 #include "lib/job_manager.h"
 #include "lib/util.h"
 #include <dcp/exceptions.h>
+#include <dcp/filesystem.h>
 #include <dcp/warnings.h>
 #include <boost/filesystem.hpp>
 #include <boost/optional.hpp>
@@ -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 ();
        }
 
index 5c6f97f995d7b4c239dbb40ddface8d81d79aa75..05ffa7a685264cfbd46a3e683f21015b3be2bd16 100644 (file)
@@ -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())
index c59607e8f4cd1b906c6a392403fbaf59a8b4d519..a035a5ffc53c981ad03910eec137158b6fce7caf 100644 (file)
@@ -27,6 +27,7 @@
 #include "lib/font.h"
 #include "lib/scope_guard.h"
 #include "lib/text_content.h"
+#include <dcp/filesystem.h>
 #include <dcp/warnings.h>
 LIBDCP_DISABLE_WARNINGS
 #include <wx/wx.h>
@@ -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";
index c61c75eced8660635dfd288ef95138fa8c29ec02..175d787309ed8c8e3dc88a3a0343cc029a17b9e7 100644 (file)
@@ -57,6 +57,7 @@
 #include "lib/util.h"
 #include <dcp/certificate_chain.h>
 #include <dcp/exceptions.h>
+#include <dcp/filesystem.h>
 #include <dcp/locale_convert.h>
 #include <dcp/warnings.h>
 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;
index 1ddaa90cf5097159251bec6f4e56caf05efd5091..2a307c60cb84ea30c31e88307c0aa2b388232771 100644 (file)
@@ -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")) {
index 1681dd1e3744f5e485bc3bc829acef6094e20ba6..84285de12e35c6d0e6f09a4f5f0bff7dc3e10ed5 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "system_font_dialog.h"
 #include "wx_util.h"
+#include <dcp/filesystem.h>
 #include <dcp/warnings.h>
 LIBDCP_DISABLE_WARNINGS
 #include <wx/listctrl.h>
@@ -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);
 
index ff4e26a574fde15398a5ef5465d06ddc8178e404..3b7973e3021760f3f32700ed7b64abb765bb3f54 100644 (file)
@@ -47,6 +47,7 @@
 #include "lib/string_text_file_decoder.h"
 #include "lib/subtitle_analysis.h"
 #include "lib/text_content.h"
+#include <dcp/filesystem.h>
 #include <dcp/warnings.h>
 LIBDCP_DISABLE_WARNINGS
 #include <wx/spinctrl.h>
@@ -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<AnalyseSubtitlesJob>(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 ();
index 630026120736327eb22cea872c9a5772f4315f8b..9b08dfb4e8619c8fe00cc70a16ae5e3b81fd69a6 100644 (file)
@@ -46,6 +46,7 @@
 #include <dcp/cpl.h>
 #include <dcp/dcp.h>
 #include <dcp/equality_options.h>
+#include <dcp/filesystem.h>
 #include <dcp/mono_picture_asset.h>
 #include <dcp/mono_picture_frame.h>
 #include <dcp/openjpeg_image.h>
@@ -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";
 }
 
 
index 1b8c386f4356e369090266be63e51a4f8abc5f1a..37e6176f0d322882df7694a9628f4b10c20d302a 100644 (file)
@@ -28,6 +28,7 @@
 #include "lib/exceptions.h"
 #include "lib/zipper.h"
 #include "test.h"
+#include <dcp/filesystem.h>
 #include <dcp/util.h>
 #include <boost/test/unit_test.hpp>
 #include <boost/filesystem.hpp>
@@ -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)