X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7da60d7c18d4b7a9ed586208cc6174b87b55db91..cb0791531fff2f3673e28d68be67a0ee5398a036:/src/common/filename.cpp diff --git a/src/common/filename.cpp b/src/common/filename.cpp index 1fd38e5e25..9553e92a27 100644 --- a/src/common/filename.cpp +++ b/src/common/filename.cpp @@ -453,9 +453,21 @@ void wxFileName::Assign(const wxString& fullpathOrig, Assign(volume, path, name, ext, format); } +void wxFileName::Assign(const wxString& pathOrig, + const wxString& name, + const wxString& ext, + wxPathFormat format) +{ + wxString volume, + path; + SplitVolume(pathOrig, &volume, &path, format); + + Assign(volume, path, name, ext, format); +} + void wxFileName::AssignDir(const wxString& dir, wxPathFormat format) { - Assign(dir, _T(""), format); + Assign(dir, wxEmptyString, format); } void wxFileName::Clear() @@ -1063,7 +1075,7 @@ bool wxFileName::GetShortcutTarget(const wxString& shortcutPath, wxString& targe psl->GetArguments(buf, 2048); wxString args(buf); - if (!args.IsEmpty() && arguments) + if (!args.empty() && arguments) { *arguments = args; } @@ -1181,17 +1193,15 @@ bool wxFileName::IsCaseSensitive( wxPathFormat format ) return GetFormat(format) == wxPATH_UNIX; } -// If asserts, wxPathFormat has been changed. -wxCOMPILE_TIME_ASSERT(wxPATH_MAX == 5, wxPathFormatChanged); - /* static */ wxString wxFileName::GetForbiddenChars(wxPathFormat format) { // Inits to forbidden characters that are common to (almost) all platforms. wxString strForbiddenChars = wxT("*?"); - // In case of a new path format + // If asserts, wxPathFormat has been changed. In case of a new path format // addition, the following code might have to be updated. + wxCOMPILE_TIME_ASSERT(wxPATH_MAX == 5, wxPathFormatChanged); switch ( GetFormat(format) ) { default : @@ -1279,10 +1289,8 @@ wxString wxFileName::GetPathTerminators(wxPathFormat format) bool wxFileName::IsPathSeparator(wxChar ch, wxPathFormat format) { // wxString::Find() doesn't work as expected with NUL - it will always find - // it, so it is almost surely a bug if this function is called with NUL arg - wxASSERT_MSG( ch != _T('\0'), _T("shouldn't be called with NUL") ); - - return GetPathSeparators(format).Find(ch) != wxNOT_FOUND; + // it, so test for it separately + return ch != _T('\0') && GetPathSeparators(format).Find(ch) != wxNOT_FOUND; } // ---------------------------------------------------------------------------- @@ -1312,26 +1320,26 @@ bool wxFileName::IsPathSeparator(wxChar ch, wxPathFormat format) return true; } -void wxFileName::AppendDir( const wxString &dir ) +void wxFileName::AppendDir( const wxString& dir ) { if ( IsValidDirComponent(dir) ) m_dirs.Add( dir ); } -void wxFileName::PrependDir( const wxString &dir ) +void wxFileName::PrependDir( const wxString& dir ) { InsertDir(0, dir); } -void wxFileName::InsertDir( int before, const wxString &dir ) +void wxFileName::InsertDir(size_t before, const wxString& dir) { if ( IsValidDirComponent(dir) ) - m_dirs.Insert( dir, before ); + m_dirs.Insert(dir, before); } -void wxFileName::RemoveDir( int pos ) +void wxFileName::RemoveDir(size_t pos) { - m_dirs.RemoveAt( (size_t)pos ); + m_dirs.RemoveAt(pos); } // ---------------------------------------------------------------------------- @@ -1990,7 +1998,7 @@ public : MacDefaultExtensionRecord() { m_ext[0] = 0 ; - m_type = m_creator = NULL ; + m_type = m_creator = 0 ; } MacDefaultExtensionRecord( const MacDefaultExtensionRecord& from ) {