You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by an...@apache.org on 2017/12/09 02:36:04 UTC

[02/11] mesos git commit: Windows: Modifed `os::write` to write binary files.

Windows: Modifed `os::write` to write binary files.

By default, `write` on Windows will use Windows-style CRLF `\r\n` line
endings, regardless of the input data, which results in unexpected
behavior. Passing the `O_BINARY` flag stops Windows from changing line
endings from the original data as it is written, and so will correctly
retain LF `\n` line endings when present in the original.

Review: https://reviews.apache.org/r/60620/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/961d55b6
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/961d55b6
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/961d55b6

Branch: refs/heads/master
Commit: 961d55b64b92a5b0ca8e5cb8227bdacc59421fbc
Parents: 2ab1a31
Author: Jeff Coffler <je...@taltos.com>
Authored: Fri Dec 8 13:23:59 2017 -0800
Committer: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Committed: Fri Dec 8 16:15:08 2017 -0800

----------------------------------------------------------------------
 3rdparty/stout/include/stout/os/write.hpp | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/961d55b6/3rdparty/stout/include/stout/os/write.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/os/write.hpp b/3rdparty/stout/include/stout/os/write.hpp
index 9ff749f..4c718b1 100644
--- a/3rdparty/stout/include/stout/os/write.hpp
+++ b/3rdparty/stout/include/stout/os/write.hpp
@@ -108,7 +108,13 @@ inline Try<Nothing> write(const std::string& path, const std::string& message)
 {
   Try<int_fd> fd = os::open(
       path,
+#ifdef __WINDOWS__
+      // NOTE: The `O_BINARY` option turns off automatic translation
+      // of newline characters to Windows-style line endings.
+      O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_BINARY,
+#else
       O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC,
+#endif // __WINDOWS__
       S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
 
   if (fd.isError()) {