KiCad PCB EDA Suite
WX_FILENAME Class Reference

A wrapper around a wxFileName which is much more performant with a subset of the API. More...

#include <common.h>

Public Member Functions

 WX_FILENAME (const wxString &aPath, const wxString &aFilename)
 Performance enhancements to file and directory operations. More...
 
void SetFullName (const wxString &aFileNameAndExtension)
 
wxString GetName () const
 
wxString GetFullName () const
 
wxString GetPath () const
 
wxString GetFullPath () const
 
long long GetTimestamp ()
 

Private Member Functions

void resolve ()
 

Private Attributes

wxFileName m_fn
 
wxString m_path
 
wxString m_fullName
 

Detailed Description

A wrapper around a wxFileName which is much more performant with a subset of the API.

Definition at line 414 of file common.h.

Constructor & Destructor Documentation

◆ WX_FILENAME()

WX_FILENAME::WX_FILENAME ( const wxString &  aPath,
const wxString &  aFilename 
)

Performance enhancements to file and directory operations.

Note: while it's annoying to have to make copies of wxWidgets stuff and then add platform-specific performance optimizations, the following routines offer 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.

Definition at line 760 of file common.cpp.

760  :
761  m_fn( aPath, aFilename ),
762  m_path( aPath ),
763  m_fullName( aFilename )
764 { }
wxString m_path
Definition: common.h:434
wxFileName m_fn
Definition: common.h:433
wxString m_fullName
Definition: common.h:435

Member Function Documentation

◆ GetFullName()

wxString WX_FILENAME::GetFullName ( ) const

Definition at line 780 of file common.cpp.

781 {
782  return m_fullName;
783 }
wxString m_fullName
Definition: common.h:435

References m_fullName.

Referenced by BOOST_AUTO_TEST_CASE().

◆ GetFullPath()

wxString WX_FILENAME::GetFullPath ( ) const

Definition at line 792 of file common.cpp.

793 {
794  return m_path + wxT( '/' ) + m_fullName;
795 }
wxString m_path
Definition: common.h:434
wxString m_fullName
Definition: common.h:435

References m_fullName, and m_path.

Referenced by BOOST_AUTO_TEST_CASE(), FP_CACHE::Load(), and FP_CACHE::Save().

◆ GetName()

wxString WX_FILENAME::GetName ( void  ) const

Definition at line 773 of file common.cpp.

774 {
775  size_t dot = m_fullName.find_last_of( wxT( '.' ) );
776  return m_fullName.substr( 0, dot );
777 }
wxString m_fullName
Definition: common.h:435

References m_fullName.

Referenced by BOOST_AUTO_TEST_CASE(), and FP_CACHE::Load().

◆ GetPath()

wxString WX_FILENAME::GetPath ( ) const

Definition at line 786 of file common.cpp.

787 {
788  return m_path;
789 }
wxString m_path
Definition: common.h:434

References m_path.

Referenced by BOOST_AUTO_TEST_CASE(), and FP_CACHE::Save().

◆ GetTimestamp()

long long WX_FILENAME::GetTimestamp ( )

Definition at line 807 of file common.cpp.

808 {
809  resolve();
810 
811  if( m_fn.FileExists() )
812  return m_fn.GetModificationTime().GetValue().GetValue();
813 
814  return 0;
815 }
wxFileName m_fn
Definition: common.h:433
void resolve()
Definition: common.cpp:799

References m_fn, and resolve().

Referenced by FP_CACHE::Load(), and FP_CACHE::Save().

◆ resolve()

void WX_FILENAME::resolve ( )
private

Definition at line 799 of file common.cpp.

800 {
801  size_t dot = m_fullName.find_last_of( wxT( '.' ) );
802  m_fn.SetName( m_fullName.substr( 0, dot ) );
803  m_fn.SetExt( m_fullName.substr( dot + 1 ) );
804 }
wxFileName m_fn
Definition: common.h:433
wxString m_fullName
Definition: common.h:435

References m_fn, and m_fullName.

Referenced by GetTimestamp().

◆ SetFullName()

void WX_FILENAME::SetFullName ( const wxString &  aFileNameAndExtension)

Definition at line 767 of file common.cpp.

768 {
769  m_fullName = aFileNameAndExtension;
770 }
wxString m_fullName
Definition: common.h:435

References m_fullName.

Referenced by FP_CACHE::Load(), and GPCB_FPL_CACHE::Load().

Member Data Documentation

◆ m_fn

wxFileName WX_FILENAME::m_fn
private

Definition at line 433 of file common.h.

Referenced by GetTimestamp(), and resolve().

◆ m_fullName

wxString WX_FILENAME::m_fullName
private

Definition at line 435 of file common.h.

Referenced by GetFullName(), GetFullPath(), GetName(), resolve(), and SetFullName().

◆ m_path

wxString WX_FILENAME::m_path
private

Definition at line 434 of file common.h.

Referenced by GetFullPath(), and GetPath().


The documentation for this class was generated from the following files: