X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2049ba38adafa0ec146880de29f26e32dd69a125..275bf4c13ab7f4b041b0d5c78cfdece709800d14:/src/common/filefn.cpp diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index 2a17499d5e..7934074852 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -267,6 +267,21 @@ void wxStripExtension(char *buffer) } } +void wxStripExtension(wxString& buffer) +{ + size_t len = buffer.Length(); + size_t i = len-1; + while (i > 0) + { + if (buffer.GetChar(i) == '.') + { + buffer = buffer.Left(i); + break; + } + i --; + } +} + // Destructive removal of /./ and /../ stuff char *wxRealPath (char *path) { @@ -721,7 +736,11 @@ wxDos2UnixFilename (char *s) } void +#ifdef __WXMSW__ wxUnix2DosFilename (char *s) +#else +wxUnix2DosFilename (char *WXUNUSED(s)) +#endif { // Yes, I really mean this to happen under DOS only! JACS #ifdef __WXMSW__ @@ -1315,3 +1334,37 @@ bool wxFindFileInPath(wxString *pStr, const char *pszPath, const char *pszFile) return pc != NULL; // if true => we breaked from the loop } +void WXDLLEXPORT wxSplitPath(const char *pszFileName, + wxString *pstrPath, + wxString *pstrName, + wxString *pstrExt) +{ + wxCHECK_RET( pszFileName, "NULL file name in wxSplitPath" ); + + const char *pDot = strrchr(pszFileName, FILE_SEP_EXT); + const char *pSepUnix = strrchr(pszFileName, FILE_SEP_PATH_UNIX); + const char *pSepDos = strrchr(pszFileName, FILE_SEP_PATH_DOS); + + // take the last of the two + uint nPosUnix = pSepUnix ? pSepUnix - pszFileName : 0; + uint nPosDos = pSepDos ? pSepDos - pszFileName : 0; + if ( nPosDos > nPosUnix ) + nPosUnix = nPosDos; +// uint nLen = Strlen(pszFileName); + + if ( pstrPath ) + *pstrPath = wxString(pszFileName, nPosUnix); + if ( pDot ) { + uint nPosDot = pDot - pszFileName; + if ( pstrName ) + *pstrName = wxString(pszFileName + nPosUnix + 1, nPosDot - nPosUnix); + if ( pstrExt ) + *pstrExt = wxString(pszFileName + nPosDot + 1); + } + else { + if ( pstrName ) + *pstrName = wxString(pszFileName + nPosUnix + 1); + if ( pstrExt ) + pstrExt->Empty(); + } +}