From 24cbcb003aca613da6006b25350e4e2596cb93bb Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Sun, 3 Mar 2019 22:23:33 +0000 Subject: [PATCH] PR libstdc++/89562 use binary mode for file I/O PR libstdc++/89562 * src/filesystem/ops-common.h (do_copy_file): Open files in binary mode for mingw. From-SVN: r269356 --- libstdc++-v3/ChangeLog | 6 ++++++ libstdc++-v3/src/filesystem/ops-common.h | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 9c4ef40..70cfef0 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2019-03-03 Jonathan Wakely + + PR libstdc++/89562 + * src/filesystem/ops-common.h (do_copy_file): Open files in binary + mode for mingw. + 2019-03-01 Jonathan Wakely * testsuite/util/testsuite_allocator.h (__gnu_test::memory_resource) diff --git a/libstdc++-v3/src/filesystem/ops-common.h b/libstdc++-v3/src/filesystem/ops-common.h index 55e482f..6dc9b13 100644 --- a/libstdc++-v3/src/filesystem/ops-common.h +++ b/libstdc++-v3/src/filesystem/ops-common.h @@ -402,7 +402,12 @@ _GLIBCXX_BEGIN_NAMESPACE_FILESYSTEM int fd; }; - CloseFD in = { posix::open(from, O_RDONLY) }; + int iflag = O_RDONLY; +#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + iflag |= O_BINARY; +#endif + + CloseFD in = { posix::open(from, iflag) }; if (in.fd == -1) { ec.assign(errno, std::generic_category()); @@ -413,6 +418,9 @@ _GLIBCXX_BEGIN_NAMESPACE_FILESYSTEM oflag |= O_TRUNC; else oflag |= O_EXCL; +#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + oflag |= O_BINARY; +#endif CloseFD out = { posix::open(to, oflag, S_IWUSR) }; if (out.fd == -1) { -- 2.7.4