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 397 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 630 of file common.cpp.

630  :
631  m_fn( aPath, aFilename ),
632  m_path( aPath ),
633  m_fullName( aFilename )
634 { }
wxString m_path
Definition: common.h:417
wxFileName m_fn
Definition: common.h:416
wxString m_fullName
Definition: common.h:418

Member Function Documentation

◆ GetFullName()

wxString WX_FILENAME::GetFullName ( ) const

Definition at line 650 of file common.cpp.

651 {
652  return m_fullName;
653 }
wxString m_fullName
Definition: common.h:418

References m_fullName.

◆ GetFullPath()

wxString WX_FILENAME::GetFullPath ( ) const

Definition at line 662 of file common.cpp.

663 {
664  return m_path + wxT( '/' ) + m_fullName;
665 }
wxString m_path
Definition: common.h:417
wxString m_fullName
Definition: common.h:418

References m_fullName, and m_path.

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

◆ GetName()

wxString WX_FILENAME::GetName ( void  ) const

Definition at line 643 of file common.cpp.

644 {
645  size_t dot = m_fullName.find_last_of( wxT( '.' ) );
646  return m_fullName.substr( 0, dot );
647 }
wxString m_fullName
Definition: common.h:418

References m_fullName.

Referenced by FP_CACHE::Load().

◆ GetPath()

wxString WX_FILENAME::GetPath ( ) const

Definition at line 656 of file common.cpp.

657 {
658  return m_path;
659 }
wxString m_path
Definition: common.h:417

References m_path.

Referenced by FP_CACHE::Save().

◆ GetTimestamp()

long long WX_FILENAME::GetTimestamp ( )

Definition at line 677 of file common.cpp.

678 {
679  resolve();
680 
681  if( m_fn.FileExists() )
682  return m_fn.GetModificationTime().GetValue().GetValue();
683 
684  return 0;
685 }
wxFileName m_fn
Definition: common.h:416
void resolve()
Definition: common.cpp:669

References m_fn, and resolve().

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

◆ resolve()

void WX_FILENAME::resolve ( )
private

Definition at line 669 of file common.cpp.

670 {
671  size_t dot = m_fullName.find_last_of( wxT( '.' ) );
672  m_fn.SetName( m_fullName.substr( 0, dot ) );
673  m_fn.SetExt( m_fullName.substr( dot + 1 ) );
674 }
wxFileName m_fn
Definition: common.h:416
wxString m_fullName
Definition: common.h:418

References m_fn, and m_fullName.

Referenced by GetTimestamp().

◆ SetFullName()

void WX_FILENAME::SetFullName ( const wxString &  aFileNameAndExtension)

Definition at line 637 of file common.cpp.

638 {
639  m_fullName = aFileNameAndExtension;
640 }
wxString m_fullName
Definition: common.h:418

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 416 of file common.h.

Referenced by GetTimestamp(), and resolve().

◆ m_fullName

wxString WX_FILENAME::m_fullName
private

Definition at line 418 of file common.h.

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

◆ m_path

wxString WX_FILENAME::m_path
private

Definition at line 417 of file common.h.

Referenced by GetFullPath(), and GetPath().


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