aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2019-03-03 22:23:33 +0000
committerJonathan Wakely <redi@gcc.gnu.org>2019-03-03 22:23:33 +0000
commit24cbcb003aca613da6006b25350e4e2596cb93bb (patch)
treeecfb7a2649755c39e96b7f8a8bc27fab75ac0453
parentde06e54d21f8a128289e40f12811b321778f9a8f (diff)
downloadgcc-24cbcb003aca613da6006b25350e4e2596cb93bb.zip
gcc-24cbcb003aca613da6006b25350e4e2596cb93bb.tar.gz
gcc-24cbcb003aca613da6006b25350e4e2596cb93bb.tar.bz2
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
-rw-r--r--libstdc++-v3/ChangeLog6
-rw-r--r--libstdc++-v3/src/filesystem/ops-common.h10
2 files changed, 15 insertions, 1 deletions
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 <jwakely@redhat.com>
+
+ PR libstdc++/89562
+ * src/filesystem/ops-common.h (do_copy_file): Open files in binary
+ mode for mingw.
+
2019-03-01 Jonathan Wakely <jwakely@redhat.com>
* 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)
{