X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/34e2d9439b84617ca61a52354bdb18c1ce5546fb..f1f5f16f780bb41aa2ea24ccbf728f14c86cc475:/src/common/filefn.cpp diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index d690e66d9d..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; @@ -1779,7 +1817,7 @@ int WXDLLEXPORT wxParseCommonDialogsFilter(const wxString& filterStr, return filters.GetCount(); } -#if defined( __WINDOWS__ ) +#if defined(__WINDOWS__) && !(defined(__UNIX__) || defined(__OS2__)) static bool wxCheckWin32Permission(const wxString& path, DWORD access) { // quoting the MSDN: "To obtain a handle to a directory, call the @@ -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;