+// We really only want to use g_open for all platforms but because of this
+// method(SndfileSource::open), the compiler(or at least GCC) is confused
+// because g_open will expand to "open" on non-POSIX systems and needs the
+// global namespace qualifer. The problem is since since C99 ::g_open will
+// apparently expand to ":: open"
+#ifdef PLATFORM_WINDOWS
+ int fd = g_open (_path.c_str(), writable() ? O_CREAT | O_RDWR : O_RDONLY, writable() ? 0644 : 0444);
+#else
+ int fd = ::open (_path.c_str(), writable() ? O_CREAT | O_RDWR : O_RDONLY, writable() ? 0644 : 0444);
+#endif
+
+ if (fd == -1) {
+ error << string_compose (
+ _ ("SndFileSource: cannot open file \"%1\" for %2"),
+ _path,
+ (writable () ? "read+write" : "reading")) << endmsg;
+ return -1;
+ }
+
+ _sndfile = sf_open_fd (fd, writable() ? SFM_RDWR : SFM_READ, &_info, true);
+
+ if (_sndfile == 0) {
+ char errbuf[1024];