#define R_OK 4
#endif
-// there is no distinction between text and binary files under Unix
-#ifdef __UNIX__
+// there is no distinction between text and binary files under Unix, so define
+// O_BINARY as 0 if the system headers don't do it already
+#if defined(__UNIX__) && !defined(O_BINARY)
#define O_BINARY (0)
#endif //__UNIX__
// if bOverwrite we create a new file or truncate the existing one,
// otherwise we only create the new file and fail if it already exists
#ifdef __WXMAC__
- int fd = open(wxUnix2MacFilename( szFileName ), O_CREAT | (bOverwrite ? O_TRUNC : O_EXCL), access);
+ int fd = open(wxUnix2MacFilename( szFileName ), O_CREAT | (bOverwrite ? O_TRUNC : O_EXCL), access);
#else
int fd = open(wxFNCONV(szFileName),
- O_WRONLY | O_CREAT | (bOverwrite ? O_TRUNC : O_EXCL)
+ O_BINARY | O_WRONLY | O_CREAT |
+ (bOverwrite ? O_TRUNC : O_EXCL)
ACCESS(accessMode));
#endif
if ( fd == -1 ) {
}
#ifdef __WXMAC__
- int fd = open(wxUnix2MacFilename( szFileName ), flags, access);
+ int fd = open(wxUnix2MacFilename( szFileName ), flags, access);
#else
int fd = open(wxFNCONV(szFileName), flags ACCESS(accessMode));
#endif