summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2021-03-08 16:36:08 +0100
committerMax Kellermann <max@musicpd.org>2021-03-08 17:25:36 +0100
commitd61341c0e3769ec4b9bfb7c2f2b0e98cd3834741 (patch)
treeea1c46000aa407afbc511882dd95061be2ea1f1e /src
parenteff50b263a9b0a738e0f26d08b2a5ce782761b7c (diff)
io/FileDescriptor: add method SetBinaryMode()
Diffstat (limited to 'src')
-rw-r--r--src/io/FileDescriptor.cxx10
-rw-r--r--src/io/FileDescriptor.hxx3
2 files changed, 12 insertions, 1 deletions
diff --git a/src/io/FileDescriptor.cxx b/src/io/FileDescriptor.cxx
index 08b457831..8351446c6 100644
--- a/src/io/FileDescriptor.cxx
+++ b/src/io/FileDescriptor.cxx
@@ -172,7 +172,15 @@ FileDescriptor::CreatePipe(FileDescriptor &r, FileDescriptor &w) noexcept
#endif
}
-#ifndef _WIN32
+#ifdef _WIN32
+
+void
+FileDescriptor::SetBinaryMode() noexcept
+{
+ _setmode(fd, _O_BINARY);
+}
+
+#else // !_WIN32
bool
FileDescriptor::CreatePipeNonBlock(FileDescriptor &r,
diff --git a/src/io/FileDescriptor.hxx b/src/io/FileDescriptor.hxx
index 186c5870c..a036d0d58 100644
--- a/src/io/FileDescriptor.hxx
+++ b/src/io/FileDescriptor.hxx
@@ -148,10 +148,13 @@ public:
#ifdef _WIN32
void EnableCloseOnExec() noexcept {}
void DisableCloseOnExec() noexcept {}
+ void SetBinaryMode() noexcept;
#else
static bool CreatePipeNonBlock(FileDescriptor &r,
FileDescriptor &w) noexcept;
+ void SetBinaryMode() noexcept {}
+
/**
* Enable non-blocking mode on this file descriptor.
*/