X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8daf3c366409ae9b9f657370c43cc15896704b14..e17b6377be593ce71d722beb3cdcffb67baccf00:/src/common/filefn.cpp diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index 451ec6d421..6fe03ab10a 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -146,11 +146,15 @@ WXDLLEXPORT int wxOpen( const wxChar *pathname, int flags, mode_t mode ) // wxPathList // ---------------------------------------------------------------------------- -void wxPathList::Add (const wxString& path) +void wxPathList::Add(const wxString& path) { - // add only the path part of the given string (not the filename, in case it's present) + // add a path separator to force wxFileName to interpret it always as a directory + // (i.e. if we are called with '/home/user' we want to consider it a folder and + // not, as wxFileName would consider, a filename). wxFileName fn(path + wxFileName::GetPathSeparator()); - fn.Normalize(); // add only normalized paths + + // add only normalized relative/absolute paths + fn.Normalize(wxPATH_NORM_DOTS|wxPATH_NORM_TILDE|wxPATH_NORM_LONG|wxPATH_NORM_ENV_VARS); wxString toadd = fn.GetPath(); if (Index(toadd) == wxNOT_FOUND) @@ -211,12 +215,17 @@ bool wxPathList::Member (const wxString& path) const wxString wxPathList::FindValidPath (const wxString& file) const { + // normalize the given string as it could be a path + a filename + // and not only a filename wxFileName fn(file); wxString strend; - fn.Normalize(); + // NB: normalize without making absolute ! + fn.Normalize(wxPATH_NORM_DOTS|wxPATH_NORM_TILDE|wxPATH_NORM_LONG|wxPATH_NORM_ENV_VARS); + + wxASSERT_MSG(!fn.IsDir(), wxT("Cannot search for directories; only for files")); if (fn.IsAbsolute()) - strend = fn.GetFullName(); + strend = fn.GetFullName(); // search for the file name and ignore the path part else strend = fn.GetFullPath(); @@ -1391,7 +1400,7 @@ wxChar *wxDoGetCwd(wxChar *buf, int sz) #ifdef HAVE_WGETCWD #if wxUSE_UNICODE_MSLU - if ( wxGetOsVersion() != wxWIN95 ) + if ( wxGetOsVersion() != wxOS_WINDOWS_9X ) #else char *cbuf = NULL; // never really used because needsANSI will always be false #endif @@ -1625,6 +1634,8 @@ void WXDLLEXPORT wxSplitPath(const wxChar *pszFileName, wxFileName::SplitPath(pszFileName, pstrPath, pstrName, pstrExt); } +#if wxUSE_DATETIME + time_t WXDLLEXPORT wxFileModificationTime(const wxString& filename) { wxDateTime mtime; @@ -1634,6 +1645,8 @@ time_t WXDLLEXPORT wxFileModificationTime(const wxString& filename) return mtime.GetTicks(); } +#endif // wxUSE_DATETIME + // Parses the filterStr, returning the number of filters. // Returns 0 if none or if there's a problem.