X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7c74e7fe1de14f32dcd6f3c9cdd727de540bbd0e..c0eba78b86232bf8c2ef886e0a35808ab09df25f:/src/common/file.cpp diff --git a/src/common/file.cpp b/src/common/file.cpp index 89d17ff691..ef24f40f83 100644 --- a/src/common/file.cpp +++ b/src/common/file.cpp @@ -122,8 +122,9 @@ #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__ @@ -219,10 +220,11 @@ bool wxFile::Create(const wxChar *szFileName, bool bOverwrite, int accessMode) // 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 ) { @@ -259,7 +261,7 @@ bool wxFile::Open(const wxChar *szFileName, OpenMode mode, int accessMode) } #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