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
This commit is contained in:
Jonathan Wakely 2019-03-03 22:23:33 +00:00 committed by Jonathan Wakely
parent de06e54d21
commit 24cbcb003a
2 changed files with 15 additions and 1 deletions

View File

@ -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)

View File

@ -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)
{