summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2013-06-07 19:33:20 +0200
committerRobin Gareus <robin@gareus.org>2013-06-07 19:33:20 +0200
commit07c6df00cc20057595a5da4219988b8239e9beff (patch)
treedee2a3827b5ac1e0ea670ef1aee095b15d77a8c7
parent327ec5f58e58224e01004ddfd0252a840a0e84f0 (diff)
fix use of sf_open_fd() instad of sf_open()
-rw-r--r--libs/pbd/sndfile_manager.cc29
1 files changed, 27 insertions, 2 deletions
diff --git a/libs/pbd/sndfile_manager.cc b/libs/pbd/sndfile_manager.cc
index c3fbd7be5b..53e3c5ce00 100644
--- a/libs/pbd/sndfile_manager.cc
+++ b/libs/pbd/sndfile_manager.cc
@@ -31,6 +31,16 @@
#include "pbd/sndfile_manager.h"
#include "pbd/debug.h"
+/*
+ * Neat solution to the Win32/OS2 binary file flage requirement.
+ * If O_BINARY isn't already defined by the inclusion of the system
+ * headers, set it to zero.
+ */
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+
using namespace std;
using namespace PBD;
@@ -89,8 +99,23 @@ bool
SndFileDescriptor::open ()
{
/* we must have a lock on the FileManager's mutex */
-
- int fd = ::open(_path.c_str(), O_LARGEFILE | (_writeable ? (O_RDWR|O_CREAT) : O_RDONLY));
+
+ int fd, oflag, mode ;
+
+ if (_writeable) {
+ oflag = O_RDWR | O_CREAT | O_BINARY ;
+ mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH ;
+ } else {
+ oflag = O_RDONLY | O_BINARY ;
+ mode = 0 ;
+ }
+
+ if (mode == 0) {
+ fd = ::open (_path.c_str(), oflag) ;
+ } else {
+ fd = ::open (_path.c_str(), oflag, mode) ;
+ }
+
if (fd == -1) return false;
fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);