- 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
- size_t nPosUnix = pSepUnix ? pSepUnix - pszFileName : 0;
- size_t nPosDos = pSepDos ? pSepDos - pszFileName : 0;
- if ( nPosDos > nPosUnix )
- nPosUnix = nPosDos;
-// size_t nLen = Strlen(pszFileName);
-
- if ( pstrPath )
- *pstrPath = wxString(pszFileName, nPosUnix);
- if ( pDot ) {
- size_t nPosDot = pDot - pszFileName;
- if ( pstrName )
- *pstrName = wxString(pszFileName + nPosUnix + 1, nPosDot - nPosUnix);
- if ( pstrExt )
- *pstrExt = wxString(pszFileName + nPosDot + 1);
- }
- else {
+ // it can be empty, but it shouldn't be NULL
+ wxCHECK_RET( pszFileName, _T("NULL file name in wxSplitPath") );
+
+ const wxChar *pDot = wxStrrchr(pszFileName, wxFILE_SEP_EXT);
+
+#ifdef __WXMSW__
+ // under Windows we understand both separators
+ const wxChar *pSepUnix = wxStrrchr(pszFileName, wxFILE_SEP_PATH_UNIX);
+ const wxChar *pSepDos = wxStrrchr(pszFileName, wxFILE_SEP_PATH_DOS);
+ const wxChar *pLastSeparator = pSepUnix > pSepDos ? pSepUnix : pSepDos;
+#else // assume Unix
+ const wxChar *pLastSeparator = wxStrrchr(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;
+ }
+
+ if ( pstrPath )
+ {
+ if ( pLastSeparator )
+ *pstrPath = wxString(pszFileName, pLastSeparator - pszFileName);
+ else
+ pstrPath->Empty();
+ }
+