X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/25db2c25bc488fcdd10cc5d2fd4938fd78b1cf0e..8fdbcf4de8eeff67ccfaf3deec833d203f112629:/src/common/filename.cpp diff --git a/src/common/filename.cpp b/src/common/filename.cpp index 31251fcdcb..d6d68aeeb6 100644 --- a/src/common/filename.cpp +++ b/src/common/filename.cpp @@ -99,7 +99,9 @@ #endif #ifdef __WINDOWS__ -#include "wx/msw/private.h" + #include "wx/msw/private.h" + #include // for CLSID_ShellLink + #include "wx/msw/missing.h" #endif #if defined(__WXMAC__) @@ -606,11 +608,10 @@ void wxFileName::AssignDir(const wxString& dir, wxPathFormat format) void wxFileName::Clear() { - m_dirs.Clear(); - - m_volume = - m_name = - m_ext = wxEmptyString; + m_dirs.clear(); + m_volume.clear(); + m_name.clear(); + m_ext.clear(); // we don't have any absolute path for now m_relative = true; @@ -737,7 +738,12 @@ wxFileSystemObjectExists(const wxString& path, int flags) if ( S_ISDIR(st.st_mode) ) return acceptDir; if ( S_ISLNK(st.st_mode) ) - return (flags & wxFILE_EXISTS_SYMLINK) != 0; + { + // Take care to not test for "!= 0" here as this would erroneously + // return true if only wxFILE_EXISTS_NO_FOLLOW, which is part of + // wxFILE_EXISTS_SYMLINK, is set too. + return (flags & wxFILE_EXISTS_SYMLINK) == wxFILE_EXISTS_SYMLINK; + } if ( S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode) ) return (flags & wxFILE_EXISTS_DEVICE) != 0; if ( S_ISFIFO(st.st_mode) ) @@ -1422,8 +1428,7 @@ bool wxFileName::Rmdir(const wxString& dir, int flags) // this directory itself even when it is a symlink -- but without // following it. Do it here as wxRmdir() would simply follow if // called for a symlink. - if ( wxFileName::Exists(dir, wxFILE_EXISTS_SYMLINK | - wxFILE_EXISTS_NO_FOLLOW) ) + if ( wxFileName::Exists(dir, wxFILE_EXISTS_SYMLINK) ) { return wxRemoveFile(dir); } @@ -1698,13 +1703,6 @@ bool wxFileName::ReplaceHomeDir(wxPathFormat format) // quotation marks." #if defined(__WIN32__) && !defined(__WXWINCE__) && wxUSE_OLE -// The following lines are necessary under WinCE -// #include "wx/msw/private.h" -// #include -#include -#if defined(__WXWINCE__) -#include -#endif bool wxFileName::GetShortcutTarget(const wxString& shortcutPath, wxString& targetFilename, @@ -1913,7 +1911,7 @@ wxString wxFileName::GetForbiddenChars(wxPathFormat format) case wxPATH_MAC: // On a Mac even names with * and ? are allowed (Tested with OS // 9.2.1 and OS X 10.2.5) - strForbiddenChars = wxEmptyString; + strForbiddenChars.clear(); break; case wxPATH_DOS: @@ -2035,10 +2033,12 @@ wxFileName::IsMSWUniqueVolumeNamePath(const wxString& path, wxPathFormat format) return true; } -void wxFileName::AppendDir( const wxString& dir ) +bool wxFileName::AppendDir( const wxString& dir ) { - if ( IsValidDirComponent(dir) ) - m_dirs.Add( dir ); + if (!IsValidDirComponent(dir)) + return false; + m_dirs.Add(dir); + return true; } void wxFileName::PrependDir( const wxString& dir ) @@ -2046,10 +2046,12 @@ void wxFileName::PrependDir( const wxString& dir ) InsertDir(0, dir); } -void wxFileName::InsertDir(size_t before, const wxString& dir) +bool wxFileName::InsertDir(size_t before, const wxString& dir) { - if ( IsValidDirComponent(dir) ) - m_dirs.Insert(dir, before); + if (!IsValidDirComponent(dir)) + return false; + m_dirs.Insert(dir, before); + return true; } void wxFileName::RemoveDir(size_t pos) @@ -2291,7 +2293,7 @@ wxString wxFileName::GetLongPath() const GetVolumeSeparator(wxPATH_DOS) + GetPathSeparator(wxPATH_DOS); else - pathOut = wxEmptyString; + pathOut.clear(); wxArrayString dirs = GetDirs(); dirs.Add(GetFullName());