X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/968956aa6e30195516f8d645b7b7b7b622948d7b..f1f5f16f780bb41aa2ea24ccbf728f14c86cc475:/src/common/filefn.cpp diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index 8a8b921abf..1d0a96278c 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -152,6 +152,44 @@ WXDLLEXPORT int wxOpen( const wxChar *pathname, int flags, mode_t mode ) #endif // wxNEED_WX_UNISTD_H +#if wxUSE_UNICODE && defined __BORLANDC__ \ + && __BORLANDC__ >= 0x550 && __BORLANDC__ <= 0x551 + +// BCC 5.5 and 5.5.1 have a bug in _wopen where files are created read only +// regardless of the mode parameter. This hack works around the problem by +// setting the mode with _wchmod. +// +int wxOpen(const wchar_t *pathname, int flags, mode_t mode) +{ + int moreflags = 0; + + // we only want to fix the mode when the file is actually created, so + // when creating first try doing it O_EXCL so we can tell if the file + // was already there. + if ((flags & O_CREAT) && !(flags & O_EXCL) && (mode & wxS_IWUSR) != 0) + moreflags = O_EXCL; + + int fd = _wopen(pathname, flags | moreflags, mode); + + // the file was actually created and needs fixing + if (fd != -1 && (flags & O_CREAT) != 0 && (mode & wxS_IWUSR) != 0) + { + close(fd); + _wchmod(pathname, mode); + fd = _wopen(pathname, flags & ~(O_EXCL | O_CREAT)); + } + // the open failed, but it may have been because the added O_EXCL stopped + // the opening of an existing file, so try again without. + else if (fd == -1 && moreflags != 0) + { + fd = _wopen(pathname, flags & ~O_CREAT); + } + + return fd; +} + +#endif + // ---------------------------------------------------------------------------- // wxPathList // ---------------------------------------------------------------------------- @@ -1232,7 +1270,7 @@ bool wxRmdir(const wxString& dir, int WXUNUSED(flags)) #elif defined(__OS2__) return (::DosDeleteDir((PSZ)dir.c_str()) == 0); #elif defined(__WXWINCE__) - return (CreateDirectory(dir, NULL) != 0); + return (RemoveDirectory(dir) != 0); #elif defined(__WXPALMOS__) // TODO with VFSFileRename() return false; @@ -1918,7 +1956,7 @@ wxFileKind wxGetFileKind(FILE *fp) #if defined(wxFILEKIND_STUB) || wxONLY_WATCOM_EARLIER_THAN(1,4) (void)fp; return wxFILE_KIND_DISK; -#elif defined(__WINDOWS__) && !defined(__CYGWIN__) && !defined(__WATCOMC__) +#elif defined(__WINDOWS__) && !defined(__CYGWIN__) && !defined(__WATCOMC__) && !defined(__WINE__) return fp ? wxGetFileKind(_fileno(fp)) : wxFILE_KIND_UNKNOWN; #else return fp ? wxGetFileKind(fileno(fp)) : wxFILE_KIND_UNKNOWN;