diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-09-25 02:10:44 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-09-25 02:10:44 +0200 |
| commit | c0418f2a763407424d986c82ed147fbeaa2d9416 (patch) | |
| tree | d59c1e80a82b5d25d1f48bbfe4790126ba865077 /src/filesystem.cc | |
| parent | 540b9948e4a2fd4e52a2b29ed2089a0dc61d4cc6 (diff) | |
| parent | 152266f6e65451a03521eb04b6a406b6e309e17a (diff) | |
Merge remote-tracking branch 'origin/main' into v1.9.xv1.9.22
Diffstat (limited to 'src/filesystem.cc')
| -rw-r--r-- | src/filesystem.cc | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/filesystem.cc b/src/filesystem.cc index 428bb029..4cbbc3d4 100644 --- a/src/filesystem.cc +++ b/src/filesystem.cc @@ -107,9 +107,15 @@ dcp::filesystem::copy_file(boost::filesystem::path const& from, boost::filesyste void -dcp::filesystem::copy_file(boost::filesystem::path const& from, boost::filesystem::path const& to, boost::filesystem::copy_option option) +dcp::filesystem::copy_file(boost::filesystem::path const& from, boost::filesystem::path const& to, CopyOptions option) { - boost::filesystem::copy_file(dcp::filesystem::fix_long_path(from), dcp::filesystem::fix_long_path(to), option); +#ifdef LIBDCP_HAVE_COPY_OPTIONS + auto const options = option == CopyOptions::OVERWRITE_EXISTING ? boost::filesystem::copy_options::overwrite_existing : boost::filesystem::copy_options::none; +#else + auto const options = option == CopyOptions::OVERWRITE_EXISTING ? boost::filesystem::copy_option::overwrite_if_exists : boost::filesystem::copy_option::none; +#endif + + boost::filesystem::copy_file(dcp::filesystem::fix_long_path(from), dcp::filesystem::fix_long_path(to), options); } @@ -247,7 +253,7 @@ dcp::filesystem::create_symlink(boost::filesystem::path const& from, boost::file std::string dcp::filesystem::extension(boost::filesystem::path const& path) { - return boost::filesystem::extension(dcp::filesystem::fix_long_path(path)); + return dcp::filesystem::fix_long_path(path).extension().string(); } @@ -297,7 +303,13 @@ dcp::filesystem::rename(boost::filesystem::path const& old_path, boost::filesyst boost::filesystem::path dcp::filesystem::change_extension(boost::filesystem::path const& path, std::string const& new_extension) { +#ifdef LIBDCP_HAVE_REPLACE_EXTENSION + auto copy = path; + copy.replace_extension(new_extension); + return copy; +#else return boost::filesystem::change_extension(path, new_extension); +#endif } |
