diff options
author | Tim Mayberry <mojofunk@gmail.com> | 2014-06-25 09:05:43 +1000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2014-06-25 12:40:11 -0400 |
commit | de4fc4843b7975eb1a44622845e0e2942cf1d119 (patch) | |
tree | 4d1da4f877d0aa10fc659bada1efb04b17a6334f /libs/pbd/file_utils.cc | |
parent | 3000399ce1ba37c197a404d8c294ee2260e87468 (diff) |
Fix PBD::copy_files so that it uses O_BINARY on windows and doesn't add line endings to copied files
Diffstat (limited to 'libs/pbd/file_utils.cc')
-rw-r--r-- | libs/pbd/file_utils.cc | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libs/pbd/file_utils.cc b/libs/pbd/file_utils.cc index f4efea00f3..fd98cb733f 100644 --- a/libs/pbd/file_utils.cc +++ b/libs/pbd/file_utils.cc @@ -276,6 +276,14 @@ find_files_matching_filter (vector<string>& result, run_functor_for_paths (result, paths, filter, arg, true, pass_fullpath, return_fullpath, recurse); } +#ifdef PLATFORM_WINDOWS +#define WRITE_FLAGS O_RDWR | O_CREAT | O_BINARY +#define READ_FLAGS O_RDONLY | O_BINARY +#else +#define WRITE_FLAGS O_RDWR | O_CREAT +#define READ_FLAGS O_RDONLY +#endif + bool copy_file(const std::string & from_path, const std::string & to_path) { @@ -286,12 +294,12 @@ copy_file(const std::string & from_path, const std::string & to_path) char buf[4096]; // BUFSIZ ?? ssize_t nread; - fd_from = ::open(from_path.c_str(), O_RDONLY); + fd_from = ::open(from_path.c_str(), READ_FLAGS); if (fd_from < 0) { goto copy_error; } - fd_to = ::open(to_path.c_str(), O_WRONLY | O_CREAT, 0666); + fd_to = ::open(to_path.c_str(), WRITE_FLAGS, 0666); if (fd_to < 0) { goto copy_error; } |