From 903b61cc9dc02cc6cdbd7230159f7fb47315133f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 4 Jan 2002 01:39:22 +0000 Subject: [PATCH] fixed wxIsPathSeparator() to work for Mac git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13348 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/filefn.h | 9 ++++++++- src/common/filefn.cpp | 8 +++----- src/common/filename.cpp | 4 ++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/include/wx/filefn.h b/include/wx/filefn.h index b235f2b1dc..4d914f458f 100644 --- a/include/wx/filefn.h +++ b/include/wx/filefn.h @@ -303,7 +303,14 @@ WXDLLEXPORT bool wxRmdir(const wxString& dir, int flags = 0); // is the char a path separator? inline bool wxIsPathSeparator(wxChar c) - { return c == wxFILE_SEP_PATH_DOS || c == wxFILE_SEP_PATH_UNIX; } +{ + // under DOS/Windows we should understand both Unix and DOS file separators +#if defined(__UNIX__) || defined(__MAC__) + return c == wxFILE_SEP_PATH; +#else + return c == wxFILE_SEP_PATH_DOS || c == wxFILE_SEP_PATH_UNIX; +#endif +} // does the string ends with path separator? WXDLLEXPORT bool wxEndsWithPathSeparator(const wxChar *pszFileName); diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index 4bbe6747d1..bbaac43d90 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -1519,11 +1519,9 @@ wxString wxGetOSDirectory() bool wxEndsWithPathSeparator(const wxChar *pszFileName) { - size_t len = wxStrlen(pszFileName); - if ( len == 0 ) - return FALSE; - else - return wxIsPathSeparator(pszFileName[len - 1]); + size_t len = wxStrlen(pszFileName); + + return len && wxIsPathSeparator(pszFileName[len - 1]); } // find a file in a list of directories, returns false if not found diff --git a/src/common/filename.cpp b/src/common/filename.cpp index 0499c50adb..330828e74a 100644 --- a/src/common/filename.cpp +++ b/src/common/filename.cpp @@ -550,9 +550,9 @@ wxFileName::CreateTempFileName(const wxString& prefix, wxFile *fileTemp) { // default #ifdef __DOS__ - dir = _T("."); + dir = _T("."); #else - dir = _T("/tmp"); + dir = _T("/tmp"); #endif } #endif