X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ce045aed585af0f00b72f1cdba893b47ac2e0e55..848332140be2d53aea32d0702f4c0e06c149d24b:/src/common/filefn.cpp?ds=sidebyside diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index cb433eb7e4..bb97970acc 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: filefn.cpp +// Name: src/common/filefn.cpp // Purpose: File- and directory-related functions // Author: Julian Smart // Modified by: @@ -40,7 +40,7 @@ #include #include #include -#if !defined(__WATCOMC__) +#if !wxONLY_WATCOM_EARLIER_THAN(1,4) #if !(defined(_MSC_VER) && (_MSC_VER > 800)) #include #endif @@ -242,8 +242,7 @@ bool wxPathList::Member (const wxString& path) wxString wxPathList::FindValidPath (const wxString& file) { - if (wxFileExists (wxExpandPath(wxFileFunctionsBuffer, file))) - return wxString(wxFileFunctionsBuffer); + wxExpandPath(wxFileFunctionsBuffer, file); wxChar buf[_MAXPATHLEN]; wxStrcpy(buf, wxFileFunctionsBuffer); @@ -252,7 +251,7 @@ wxString wxPathList::FindValidPath (const wxString& file) for (wxStringList::compatibility_iterator node = GetFirst(); node; node = node->GetNext()) { - const wxChar *path = node->GetData(); + const wxString path(node->GetData()); wxStrcpy (wxFileFunctionsBuffer, path); wxChar ch = wxFileFunctionsBuffer[wxStrlen(wxFileFunctionsBuffer)-1]; if (ch != wxT('\\') && ch != wxT('/')) @@ -301,7 +300,12 @@ wxFileExists (const wxString& filename) #else // !__WIN32__ wxStructStat st; #ifndef wxNEED_WX_UNISTD_H - return wxStat( filename.fn_str() , &st) == 0 && (st.st_mode & S_IFREG); + return (wxStat( filename.fn_str() , &st) == 0 && (st.st_mode & S_IFREG)) +#ifdef __OS2__ + || (errno == EACCES) // if access is denied something with that name + // exists and is opened in exclusive mode. +#endif + ; #else return wxStat( filename , &st) == 0 && (st.st_mode & S_IFREG); #endif @@ -1237,7 +1241,13 @@ bool wxDirExists(const wxChar *pszPathName) return (ret != (DWORD)-1) && (ret & FILE_ATTRIBUTE_DIRECTORY); #elif defined(__OS2__) - return (bool)(::DosSetCurrentDir((PSZ)(WXSTRINGCAST strPath))); + FILESTATUS3 Info = {{0}}; + APIRET rc = ::DosQueryPathInfo((PSZ)(WXSTRINGCAST strPath), FIL_STANDARD, + (void*) &Info, sizeof(FILESTATUS3)); + + return ((rc == NO_ERROR) && (Info.attrFile & FILE_DIRECTORY)) || + (rc == ERROR_SHARING_VIOLATION); + // If we got a sharing violation, there must be something with this name. #else // !__WIN32__ wxStructStat st; @@ -1351,11 +1361,11 @@ wxChar *wxDoGetCwd(wxChar *buf, int sz) #if defined(__WXPALMOS__) // TODO if(buf && sz>0) buf[0] = _T('\0'); - return NULL; + return buf; #elif defined(__WXWINCE__) // TODO if(buf && sz>0) buf[0] = _T('\0'); - return NULL; + return buf; #else if ( !buf ) { @@ -1978,8 +1988,7 @@ wxFileKind wxGetFileKind(FILE *fp) { // Note: The watcom rtl dll doesn't have fileno (the static lib does). // Should be fixed in version 1.4. -#if defined(wxFILEKIND_STUB) || \ - (defined(__WATCOMC__) && __WATCOMC__ <= 1230 && defined(__SW_BR)) +#if defined(wxFILEKIND_STUB) || wxONLY_WATCOM_EARLIER_THAN(1,4) (void)fp; return wxFILE_KIND_DISK; #else