X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/debdd17e991830c4ced82f5e4672fe2b32a684c2..a0d8a3052817fef6eef27e9a6ab8802495a39db8:/src/common/filefn.cpp diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index c36a08b281..14292771e1 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -785,7 +785,7 @@ wxMac2UnixFilename (char *s) if (*s == ':') *s = '/'; else - *s = wxToLower (*s); // Case INDEPENDENT + *s = tolower(*s); // Case INDEPENDENT s++; } } @@ -830,7 +830,7 @@ wxDos2UnixFilename (char *s) *s = '/'; #ifdef __WXMSW__ else - *s = wxToLower (*s); // Case INDEPENDENT + *s = tolower(*s); // Case INDEPENDENT #endif s++; } @@ -980,8 +980,27 @@ bool wxRemoveFile(const wxString& file) return (flag == 0) ; } -bool wxMkdir(const wxString& dir) +bool wxMkdir(const wxString& dir, int perm) { +/* +#if defined( __WXMAC__ ) + strcpy( gwxMacFileName , dir ) ; + wxUnix2MacFilename( gwxMacFileName ) ; + const char *dirname = gwxMacFileName; +#else + const char *dirname = dir.c_str(); +#endif + + if ( mkdir(dirname, perm) != 0 ) + { + wxLogSysError(_("Directory '%s' couldn't be created"), dirname); + + return FALSE; + } + + return TRUE; +*/ + #if defined(__WXSTUBS__) return FALSE; #elif defined(__VMS__) @@ -995,6 +1014,7 @@ bool wxMkdir(const wxString& dir) #else return (mkdir(WXSTRINGCAST dir) == 0); #endif + } bool wxRmdir(const wxString& dir, int WXUNUSED(flags)) @@ -1279,9 +1299,6 @@ wxString wxFindFirstFile(const char *spec, int flags) if ( gs_hFileStruct == INVALID_HANDLE_VALUE ) { - wxLogSysError(_("Can not enumerate files in directory '%s'"), - path.c_str()); - result.Empty(); return result; @@ -1532,40 +1549,55 @@ void WXDLLEXPORT wxSplitPath(const char *pszFileName, wxString *pstrName, wxString *pstrExt) { - wxCHECK_RET( pszFileName, "NULL file name in wxSplitPath" ); + // it can be empty, but it shouldn't be NULL + wxCHECK_RET( pszFileName, "NULL file name in wxSplitPath" ); - const char *pDot = strrchr(pszFileName, wxFILE_SEP_EXT); - const char *pSepUnix = strrchr(pszFileName, wxFILE_SEP_PATH_UNIX); - const char *pSepDos = strrchr(pszFileName, wxFILE_SEP_PATH_DOS); + const char *pDot = strrchr(pszFileName, wxFILE_SEP_EXT); - // take the last of the two: nPosUnix containts the last slash in the - // filename - size_t nPosUnix = pSepUnix ? pSepUnix - pszFileName : 0; - size_t nPosDos = pSepDos ? pSepDos - pszFileName : 0; - if ( nPosDos > nPosUnix ) - nPosUnix = nPosDos; - - if ( pstrPath ) - *pstrPath = wxString(pszFileName, nPosUnix); +#ifdef __WXMSW__ + // under Windows we understand both separators + const char *pSepUnix = strrchr(pszFileName, wxFILE_SEP_PATH_UNIX); + const char *pSepDos = strrchr(pszFileName, wxFILE_SEP_PATH_DOS); + const char *pLastSeparator = pSepUnix > pSepDos ? pSepUnix : pSepDos; +#else // assume Unix + const char *pLastSeparator = strrchr(pszFileName, wxFILE_SEP_PATH_UNIX); + + if ( pDot == pszFileName ) + { + // under Unix files like .profile are treated in a special way + pDot = NULL; + } +#endif // MSW/Unix + + if ( pDot < pLastSeparator ) + { + // the dot is part of the path, not the start of the extension + pDot = NULL; + } - size_t nPosDot = 0; - if ( pDot ) - nPosDot = pDot - pszFileName; + if ( pstrPath ) + { + if ( pLastSeparator ) + *pstrPath = wxString(pszFileName, pLastSeparator - pszFileName); + else + pstrPath->Empty(); + } - if ( nPosDot > nPosUnix ) { - // the file name looks like "path/name.ext" - if ( pstrName ) - *pstrName = wxString(pszFileName + nPosUnix + 1, nPosDot - nPosUnix - 1); - if ( pstrExt ) - *pstrExt = wxString(pszFileName + nPosDot + 1); - } - else { - // there is either no dot at all or there is a '/' after it if ( pstrName ) - *pstrName = wxString(pszFileName + nPosUnix + 1); + { + const char *start = pLastSeparator ? pLastSeparator + 1 : pszFileName; + const char *end = pDot ? pDot : pszFileName + strlen(pszFileName); + + *pstrName = wxString(start, end - start); + } + if ( pstrExt ) - pstrExt->Empty(); - } + { + if ( pDot ) + *pstrExt = wxString(pDot + 1); + else + pstrExt->Empty(); + } } //------------------------------------------------------------------------