summaryrefslogtreecommitdiff
path: root/src/combine.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-10-06 02:04:49 +0200
committerCarl Hetherington <cth@carlh.net>2023-10-09 01:20:01 +0200
commite4b2ebd80779a44d24fe87af26ef278c1e2d97d2 (patch)
tree3bc940c5eb49c96c3c18a896c8ccd8039e6db839 /src/combine.cc
parent3be26a66645de04c7b220abeebfd2f024990a696 (diff)
Add wrappers around boost::filesystem methods that handle the
required mangling of long filenames on Windows. Also wrap lots of missing places (e.g. calls to asdcplib, libxml++, libcxml etc.) in dcp::filesystem::fix_long_path(). The idea is to keep paths un-mangled until they we call some filesystem-related API and mangle them at that point. Otherwise we end up serialising mangled names, which seems like it will not end well. Should fix DoM #2623.
Diffstat (limited to 'src/combine.cc')
-rw-r--r--src/combine.cc21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/combine.cc b/src/combine.cc
index b728298a..b7a625f0 100644
--- a/src/combine.cc
+++ b/src/combine.cc
@@ -43,6 +43,7 @@
#include "dcp.h"
#include "dcp_assert.h"
#include "exceptions.h"
+#include "filesystem.h"
#include "font_asset.h"
#include "interop_subtitle_asset.h"
#include "raw_convert.h"
@@ -52,25 +53,25 @@
#include <vector>
+using std::dynamic_pointer_cast;
using std::map;
using std::set;
+using std::shared_ptr;
using std::string;
using std::vector;
-using std::dynamic_pointer_cast;
using boost::optional;
-using std::shared_ptr;
boost::filesystem::path
make_unique (boost::filesystem::path path)
{
- if (!boost::filesystem::exists(path)) {
+ if (!dcp::filesystem::exists(path)) {
return path;
}
for (int i = 0; i < 10000; ++i) {
boost::filesystem::path p = path.parent_path() / (path.stem().string() + dcp::raw_convert<string>(i) + path.extension().string());
- if (!boost::filesystem::exists(p)) {
+ if (!dcp::filesystem::exists(p)) {
return p;
}
}
@@ -85,10 +86,10 @@ void
create_hard_link_or_copy (boost::filesystem::path from, boost::filesystem::path to)
{
try {
- create_hard_link (from, to);
+ dcp::filesystem::create_hard_link(from, to);
} catch (boost::filesystem::filesystem_error& e) {
if (e.code() == boost::system::errc::cross_device_link) {
- copy_file (from, to);
+ dcp::filesystem::copy_file(from, to);
} else {
throw;
}
@@ -107,8 +108,6 @@ dcp::combine (
shared_ptr<const CertificateChain> signer
)
{
- using namespace boost::filesystem;
-
DCP_ASSERT (!inputs.empty());
DCP output_dcp (output);
@@ -124,7 +123,7 @@ dcp::combine (
}
}
- vector<path> paths;
+ vector<boost::filesystem::path> paths;
vector<shared_ptr<dcp::Asset>> assets;
for (auto i: inputs) {
@@ -153,7 +152,7 @@ dcp::combine (
}
auto file = sub->file();
DCP_ASSERT (file);
- path new_path = make_unique(output / file->filename());
+ auto new_path = make_unique(output / file->filename());
sub->write (new_path);
add_to_container(assets, sub->font_assets());
}
@@ -168,7 +167,7 @@ dcp::combine (
if (!dynamic_pointer_cast<dcp::FontAsset>(i) && !dynamic_pointer_cast<dcp::CPL>(i)) {
auto file = i->file();
DCP_ASSERT (file);
- path new_path = make_unique(output / file->filename());
+ auto new_path = make_unique(output / file->filename());
create_hard_link_or_copy (*file, new_path);
i->set_file (new_path);
}