+void WXDLLEXPORT wxSplitPath(const wxChar *pszFileName,
+ wxString *pstrPath,
+ wxString *pstrName,
+ wxString *pstrExt)
+{
+ // it can be empty, but it shouldn't be NULL
+ wxCHECK_RET( pszFileName, wxT("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 )
+ {
+ if ( (pDot == pszFileName) || (*(pDot - 1) == wxFILE_SEP_PATH_UNIX) )
+ {
+ // under Unix, dot may be (and commonly is) the first character of the
+ // filename, don't treat the entire filename as extension in this case
+ pDot = NULL;
+ }
+ }
+#endif // MSW/Unix
+
+ if ( pDot && (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();
+ }
+
+ if ( pstrName )
+ {
+ const wxChar *start = pLastSeparator ? pLastSeparator + 1 : pszFileName;
+ const wxChar *end = pDot ? pDot : pszFileName + wxStrlen(pszFileName);
+
+ *pstrName = wxString(start, end - start);
+ }
+
+ if ( pstrExt )
+ {
+ if ( pDot )
+ *pstrExt = wxString(pDot + 1);
+ else
+ pstrExt->Empty();
+ }
+}
+
+time_t WXDLLEXPORT wxFileModificationTime(const wxString& filename)
+{
+ wxStructStat buf;
+
+ wxStat(filename.fn_str(), &buf);
+ return buf.st_mtime;
+}
+
+
+//------------------------------------------------------------------------
+// wild character routines
+//------------------------------------------------------------------------
+
+bool wxIsWild( const wxString& pattern )
+{
+ wxString tmp = pattern;
+ wxChar *pat = WXSTRINGCAST(tmp);
+ while (*pat) {
+ switch (*pat++) {
+ case wxT('?'): case wxT('*'): case wxT('['): case wxT('{'):
+ return TRUE;
+ case wxT('\\'):
+ if (!*pat++)
+ return FALSE;
+ }
+ }
+ return FALSE;
+};
+
+bool wxMatchWild( const wxString& pat, const wxString& text, bool dot_special )
+
+#if defined(HAVE_FNMATCH_H)
+{
+// this probably won't work well for multibyte chars in Unicode mode?
+ if(dot_special)
+ return fnmatch(pat.fn_str(), text.fn_str(), FNM_PERIOD) == 0;
+ else
+ return fnmatch(pat.fn_str(), text.fn_str(), 0) == 0;
+}
+#else
+
+// #pragma error Broken implementation of wxMatchWild() -- needs fixing!
+
+ /*
+ * WARNING: this code is broken!
+ */
+{
+ wxString tmp1 = pat;
+ wxChar *pattern = WXSTRINGCAST(tmp1);
+ wxString tmp2 = text;
+ wxChar *str = WXSTRINGCAST(tmp2);
+ wxChar c;
+ wxChar *cp;
+ bool done = FALSE, ret_code, ok;
+ // Below is for vi fans
+ const wxChar OB = wxT('{'), CB = wxT('}');
+
+ // dot_special means '.' only matches '.'
+ if (dot_special && *str == wxT('.') && *pattern != *str)
+ return FALSE;
+
+ while ((*pattern != wxT('\0')) && (!done)
+ && (((*str==wxT('\0'))&&((*pattern==OB)||(*pattern==wxT('*'))))||(*str!=wxT('\0')))) {
+ switch (*pattern) {
+ case wxT('\\'):
+ pattern++;
+ if (*pattern != wxT('\0'))
+ pattern++;
+ break;
+ case wxT('*'):
+ pattern++;
+ ret_code = FALSE;
+ while ((*str!=wxT('\0'))
+ && (!(ret_code=wxMatchWild(pattern, str++, FALSE))))
+ /*loop*/;
+ if (ret_code) {
+ while (*str != wxT('\0'))
+ str++;
+ while (*pattern != wxT('\0'))
+ pattern++;
+ }
+ break;
+ case wxT('['):
+ pattern++;
+ repeat:
+ if ((*pattern == wxT('\0')) || (*pattern == wxT(']'))) {
+ done = TRUE;
+ break;
+ }
+ if (*pattern == wxT('\\')) {
+ pattern++;
+ if (*pattern == wxT('\0')) {
+ done = TRUE;
+ break;
+ }
+ }
+ if (*(pattern + 1) == wxT('-')) {
+ c = *pattern;
+ pattern += 2;
+ if (*pattern == wxT(']')) {
+ done = TRUE;
+ break;
+ }
+ if (*pattern == wxT('\\')) {
+ pattern++;
+ if (*pattern == wxT('\0')) {
+ done = TRUE;
+ break;
+ }
+ }
+ if ((*str < c) || (*str > *pattern)) {
+ pattern++;
+ goto repeat;
+ }
+ } else if (*pattern != *str) {
+ pattern++;
+ goto repeat;
+ }
+ pattern++;
+ while ((*pattern != wxT(']')) && (*pattern != wxT('\0'))) {
+ if ((*pattern == wxT('\\')) && (*(pattern + 1) != wxT('\0')))
+ pattern++;
+ pattern++;
+ }
+ if (*pattern != wxT('\0')) {
+ pattern++, str++;
+ }
+ break;
+ case wxT('?'):
+ pattern++;
+ str++;
+ break;
+ case OB:
+ pattern++;
+ while ((*pattern != CB) && (*pattern != wxT('\0'))) {
+ cp = str;
+ ok = TRUE;
+ while (ok && (*cp != wxT('\0')) && (*pattern != wxT('\0'))
+ && (*pattern != wxT(',')) && (*pattern != CB)) {
+ if (*pattern == wxT('\\'))
+ pattern++;
+ ok = (*pattern++ == *cp++);
+ }
+ if (*pattern == wxT('\0')) {
+ ok = FALSE;
+ done = TRUE;
+ break;
+ } else if (ok) {
+ str = cp;
+ while ((*pattern != CB) && (*pattern != wxT('\0'))) {
+ if (*++pattern == wxT('\\')) {
+ if (*++pattern == CB)
+ pattern++;
+ }
+ }
+ } else {
+ while (*pattern!=CB && *pattern!=wxT(',') && *pattern!=wxT('\0')) {
+ if (*++pattern == wxT('\\')) {
+ if (*++pattern == CB || *pattern == wxT(','))
+ pattern++;
+ }
+ }
+ }
+ if (*pattern != wxT('\0'))
+ pattern++;
+ }
+ break;
+ default:
+ if (*str == *pattern) {
+ str++, pattern++;
+ } else {
+ done = TRUE;
+ }
+ }
+ }
+ while (*pattern == wxT('*'))
+ pattern++;
+ return ((*str == wxT('\0')) && (*pattern == wxT('\0')));
+};
+
+#endif
+
+#ifdef __VISUALC__
+ #pragma warning(default:4706) // assignment within conditional expression
+#endif // VC++