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 <wx_filename.h>

Public Member Functions

 WX_FILENAME (const wxString &aPath, const wxString &aFilename)
 
void SetFullName (const wxString &aFileNameAndExtension)
 
void SetPath (const wxString &aPath)
 
wxString GetName () const
 
wxString GetFullName () const
 
wxString GetPath () const
 
wxString GetFullPath () const
 
long long GetTimestamp ()
 

Static Public Member Functions

static void ResolvePossibleSymlinks (wxFileName &aFilename)
 

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.

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 48 of file wx_filename.h.

Constructor & Destructor Documentation

◆ WX_FILENAME()

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

Definition at line 28 of file wx_filename.cpp.

29 : m_fn( aPath, aFilename ), m_path( aPath ), m_fullName( aFilename )
30{
31}
wxString m_path
Definition: wx_filename.h:72
wxFileName m_fn
Definition: wx_filename.h:71
wxString m_fullName
Definition: wx_filename.h:73

Member Function Documentation

◆ GetFullName()

wxString WX_FILENAME::GetFullName ( ) const

Definition at line 54 of file wx_filename.cpp.

55{
56 return m_fullName;
57}

References m_fullName.

Referenced by BOOST_AUTO_TEST_CASE().

◆ GetFullPath()

wxString WX_FILENAME::GetFullPath ( ) const

Definition at line 66 of file wx_filename.cpp.

67{
68 return m_path + wxT( '/' ) + m_fullName;
69}

References m_fullName, and m_path.

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

◆ GetName()

wxString WX_FILENAME::GetName ( void  ) const

Definition at line 47 of file wx_filename.cpp.

48{
49 size_t dot = m_fullName.find_last_of( wxT( '.' ) );
50 return m_fullName.substr( 0, dot );
51}

References m_fullName.

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

◆ GetPath()

wxString WX_FILENAME::GetPath ( ) const

Definition at line 60 of file wx_filename.cpp.

61{
62 return m_path;
63}

References m_path.

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

◆ GetTimestamp()

long long WX_FILENAME::GetTimestamp ( )

Definition at line 81 of file wx_filename.cpp.

82{
83 resolve();
84
85 if( m_fn.FileExists() )
86 return m_fn.GetModificationTime().GetValue().GetValue();
87
88 return 0;
89}
void resolve()
Definition: wx_filename.cpp:73

References m_fn, and resolve().

Referenced by FP_CACHE::Save().

◆ resolve()

void WX_FILENAME::resolve ( )
private

Definition at line 73 of file wx_filename.cpp.

74{
75 size_t dot = m_fullName.find_last_of( wxT( '.' ) );
76 m_fn.SetName( m_fullName.substr( 0, dot ) );
77 m_fn.SetExt( m_fullName.substr( dot + 1 ) );
78}

References m_fn, and m_fullName.

Referenced by GetTimestamp().

◆ ResolvePossibleSymlinks()

void WX_FILENAME::ResolvePossibleSymlinks ( wxFileName &  aFilename)
static

Definition at line 92 of file wx_filename.cpp.

93{
94#ifndef __WINDOWS__
95 if( aFilename.Exists( wxFILE_EXISTS_SYMLINK ) )
96 {
97 char buffer[PATH_MAX];
98 char* realPath = realpath( TO_UTF8( aFilename.GetFullPath() ), buffer );
99
100 if( realPath )
101 aFilename.Assign( wxString::FromUTF8( realPath ) );
102 }
103#endif
104}
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96

References TO_UTF8.

Referenced by PCB_PLUGIN::FootprintSave(), SCH_LIB_PLUGIN_CACHE::GetRealFile(), PCB_EDIT_FRAME::SavePcbFile(), and SCH_EDIT_FRAME::saveSchematicFile().

◆ SetFullName()

void WX_FILENAME::SetFullName ( const wxString &  aFileNameAndExtension)

Definition at line 34 of file wx_filename.cpp.

35{
36 m_fullName = aFileNameAndExtension;
37}

References m_fullName.

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

◆ SetPath()

void WX_FILENAME::SetPath ( const wxString &  aPath)

Definition at line 40 of file wx_filename.cpp.

41{
42 m_fn.SetPath( aPath );
43 m_path = aPath;
44}

References m_fn, and m_path.

Referenced by FP_CACHE_ITEM::SetFilePath().

Member Data Documentation

◆ m_fn

wxFileName WX_FILENAME::m_fn
private

Definition at line 71 of file wx_filename.h.

Referenced by GetTimestamp(), resolve(), and SetPath().

◆ m_fullName

wxString WX_FILENAME::m_fullName
private

Definition at line 73 of file wx_filename.h.

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

◆ m_path

wxString WX_FILENAME::m_path
private

Definition at line 72 of file wx_filename.h.

Referenced by GetFullPath(), GetPath(), and SetPath().


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