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 411 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 644 of file common.cpp.

644  :
645  m_fn( aPath, aFilename ),
646  m_path( aPath ),
647  m_fullName( aFilename )
648 { }
wxString m_path
Definition: common.h:431
wxFileName m_fn
Definition: common.h:430
wxString m_fullName
Definition: common.h:432

Member Function Documentation

◆ GetFullName()

wxString WX_FILENAME::GetFullName ( ) const

Definition at line 664 of file common.cpp.

665 {
666  return m_fullName;
667 }
wxString m_fullName
Definition: common.h:432

References m_fullName.

◆ GetFullPath()

wxString WX_FILENAME::GetFullPath ( ) const

Definition at line 676 of file common.cpp.

677 {
678  return m_path + wxT( '/' ) + m_fullName;
679 }
wxString m_path
Definition: common.h:431
wxString m_fullName
Definition: common.h:432

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

658 {
659  size_t dot = m_fullName.find_last_of( wxT( '.' ) );
660  return m_fullName.substr( 0, dot );
661 }
wxString m_fullName
Definition: common.h:432

References m_fullName.

Referenced by FP_CACHE::Load().

◆ GetPath()

wxString WX_FILENAME::GetPath ( ) const

Definition at line 670 of file common.cpp.

671 {
672  return m_path;
673 }
wxString m_path
Definition: common.h:431

References m_path.

Referenced by FP_CACHE::Save().

◆ GetTimestamp()

long long WX_FILENAME::GetTimestamp ( )

Definition at line 691 of file common.cpp.

692 {
693  resolve();
694 
695  if( m_fn.FileExists() )
696  return m_fn.GetModificationTime().GetValue().GetValue();
697 
698  return 0;
699 }
wxFileName m_fn
Definition: common.h:430
void resolve()
Definition: common.cpp:683

References m_fn, and resolve().

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

◆ resolve()

void WX_FILENAME::resolve ( )
private

Definition at line 683 of file common.cpp.

684 {
685  size_t dot = m_fullName.find_last_of( wxT( '.' ) );
686  m_fn.SetName( m_fullName.substr( 0, dot ) );
687  m_fn.SetExt( m_fullName.substr( dot + 1 ) );
688 }
wxFileName m_fn
Definition: common.h:430
wxString m_fullName
Definition: common.h:432

References m_fn, and m_fullName.

Referenced by GetTimestamp().

◆ SetFullName()

void WX_FILENAME::SetFullName ( const wxString &  aFileNameAndExtension)

Definition at line 651 of file common.cpp.

652 {
653  m_fullName = aFileNameAndExtension;
654 }
wxString m_fullName
Definition: common.h:432

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

Referenced by GetTimestamp(), and resolve().

◆ m_fullName

wxString WX_FILENAME::m_fullName
private

Definition at line 432 of file common.h.

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

◆ m_path

wxString WX_FILENAME::m_path
private

Definition at line 431 of file common.h.

Referenced by GetFullPath(), and GetPath().


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