21#include <unordered_set>
29#include <wx/filename.h>
30#include <wx/translation.h>
33#define FMT_UNIMPLEMENTED wxT( "IO interface \"%s\" does not implement the \"%s\" function." )
34#define NOT_IMPLEMENTED( aCaller ) \
35 THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, \
37 wxString::FromUTF8( aCaller ) ) );
77 wxString fileExt = wxFileName( aFileName ).GetExt().MakeLower();
79 for(
const std::string& ext : exts )
81 if( fileExt == wxString( ext ).Lower() )
87 wxDir dir( aFileName );
93 std::unordered_set<wxString> lowerExts;
95 for(
const std::string& ext : exts )
96 lowerExts.emplace( wxString( ext ).MakeLower() );
100 bool cont = dir.GetFirst( &filenameStr, wxEmptyString, wxDIR_FILES | wxDIR_HIDDEN );
104 wxString ext = wxS(
"" );
106 int idx = filenameStr.Find(
'.',
true );
109 ext = filenameStr.Mid( idx + 1 ).MakeLower();
111 if( lowerExts.count( ext ) )
114 cont = dir.GetNext( &filenameStr );
virtual void AdvanceProgressPhase()
REPORTER * m_reporter
Reporter to log errors/warnings to, may be nullptr.
virtual bool DeleteLibrary(const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr)
Delete an existing library and returns true, or if library does not exist returns false,...
virtual const IO_FILE_DESC GetLibraryDesc() const =0
Get the descriptor for the library container that this IO plugin operates on.
virtual void GetLibraryOptions(std::map< std::string, UTF8 > *aListToAppendTo) const
Append supported IO options to aListToAppenTo along with internationalized descriptions.
PROGRESS_REPORTER * m_progressReporter
Progress reporter to track the progress of the operation, may be nullptr.
virtual bool CanReadLibrary(const wxString &aFileName) const
Checks if this IO object can read the specified library file/directory.
virtual bool IsLibraryWritable(const wxString &aLibraryPath)
Return true if the library at aLibraryPath is writable.
virtual void CreateLibrary(const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr)
Create a new empty library at aLibraryPath empty.
virtual void Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
virtual void AdvancePhase()=0
Use the next available virtual zone of the dialog progress bar.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
#define NOT_IMPLEMENTED(aCaller)
#define THROW_IO_ERROR(msg)
Container that describes file type info.
std::vector< std::string > m_ExtensionsInDir
In case of folders: extensions of files inside.
bool m_IsFile
Whether the library is a folder or a file.
wxString m_Description
Description shown in the file picker dialog.
std::vector< std::string > m_FileExtensions
Filter used for file pickers if m_IsFile is true.
wxString FileFilter() const
wxString AddFileExtListToFilter(const std::vector< std::string > &aExts)
Build the wildcard extension file dialog wildcard filter to add to the base message dialog.
Definition of file extensions used in Kicad.