Split wx_filename out of common
This commit is contained in:
@@ -431,71 +431,6 @@ std::ostream& operator<<( std::ostream& out, const wxPoint& pt )
|
||||
* SIGNIFICANT performance benefits.
|
||||
*/
|
||||
|
||||
/**
|
||||
* WX_FILENAME
|
||||
*
|
||||
* A wrapper around a wxFileName which avoids expensive calls to wxFileName::SplitPath()
|
||||
* and string concatenations by caching the path and filename locally and only resolving
|
||||
* the wxFileName when it has to.
|
||||
*/
|
||||
WX_FILENAME::WX_FILENAME( const wxString& aPath, const wxString& aFilename ) :
|
||||
m_fn( aPath, aFilename ),
|
||||
m_path( aPath ),
|
||||
m_fullName( aFilename )
|
||||
{ }
|
||||
|
||||
|
||||
void WX_FILENAME::SetFullName( const wxString& aFileNameAndExtension )
|
||||
{
|
||||
m_fullName = aFileNameAndExtension;
|
||||
}
|
||||
|
||||
|
||||
wxString WX_FILENAME::GetName() const
|
||||
{
|
||||
size_t dot = m_fullName.find_last_of( wxT( '.' ) );
|
||||
return m_fullName.substr( 0, dot );
|
||||
}
|
||||
|
||||
|
||||
wxString WX_FILENAME::GetFullName() const
|
||||
{
|
||||
return m_fullName;
|
||||
}
|
||||
|
||||
|
||||
wxString WX_FILENAME::GetPath() const
|
||||
{
|
||||
return m_path;
|
||||
}
|
||||
|
||||
|
||||
wxString WX_FILENAME::GetFullPath() const
|
||||
{
|
||||
return m_path + wxT( '/' ) + m_fullName;
|
||||
}
|
||||
|
||||
|
||||
// Write locally-cached values to the wxFileName. MUST be called before using m_fn.
|
||||
void WX_FILENAME::resolve()
|
||||
{
|
||||
size_t dot = m_fullName.find_last_of( wxT( '.' ) );
|
||||
m_fn.SetName( m_fullName.substr( 0, dot ) );
|
||||
m_fn.SetExt( m_fullName.substr( dot + 1 ) );
|
||||
}
|
||||
|
||||
|
||||
long long WX_FILENAME::GetTimestamp()
|
||||
{
|
||||
resolve();
|
||||
|
||||
if( m_fn.FileExists() )
|
||||
return m_fn.GetModificationTime().GetValue().GetValue();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A copy of wxMatchWild(), which wxWidgets attributes to Douglas A. Lewis
|
||||
* <[email protected]> and ircII's reg.c.
|
||||
|
||||
Reference in New Issue
Block a user