- // 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;
+ }