summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2013-07-15 07:55:36 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2013-07-15 07:55:36 -0400
commitf08d9591e6e16d81d71b8b81ff3c99d7f58c1f01 (patch)
tree101a51873319abf6fb1269d2c54fa5c912348d44 /libs
parent542c4b024e8e06d4e4b55ae6dcf20c0bc4c5344d (diff)
Fix reading and writing of files on windows in PBD::FileManager
Diffstat (limited to 'libs')
-rw-r--r--libs/pbd/file_manager.cc15
1 files changed, 13 insertions, 2 deletions
diff --git a/libs/pbd/file_manager.cc b/libs/pbd/file_manager.cc
index 0c79011af1..2cfa63ae39 100644
--- a/libs/pbd/file_manager.cc
+++ b/libs/pbd/file_manager.cc
@@ -228,8 +228,19 @@ bool
FdFileDescriptor::open ()
{
/* we must have a lock on the FileManager's mutex */
-
- _fd = ::g_open (_path.c_str(), _writeable ? (O_RDWR | O_CREAT) : O_RDONLY, _mode);
+
+ /* files must be opened with O_BINARY flag on windows
+ * or it treats the file as a text stream and puts in
+ * line endings in etc
+ */
+#ifdef WIN32
+#define WRITE_FLAGS O_RDWR | O_CREAT | O_BINARY
+#define READ_FLAGS O_RDONLY | O_BINARY
+#else
+#define WRITE_FLAGS O_RDWR | O_CREAT
+#define READ_FLAGS O_RDONLY
+#endif
+ _fd = ::g_open (_path.c_str(), _writeable ? WRITE_FLAGS : READ_FLAGS, _mode);
return (_fd == -1);
}