21#include <unordered_set>
27#include <wx/filename.h>
28#include <wx/translation.h>
31#define FMT_UNIMPLEMENTED wxT( "IO interface \"%s\" does not implement the \"%s\" function." )
32#define NOT_IMPLEMENTED( aCaller ) \
33 THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, \
35 wxString::FromUTF8( aCaller ) ) );
75 wxString fileExt = wxFileName( aFileName ).GetExt().MakeLower();
77 for(
const std::string& ext : exts )
79 if( fileExt == wxString( ext ).Lower() )
85 wxDir dir( aFileName );
91 std::unordered_set<wxString> lowerExts;
93 for(
const std::string& ext : exts )
94 lowerExts.emplace( wxString( ext ).MakeLower() );
98 bool cont = dir.GetFirst( &filenameStr, wxEmptyString, wxDIR_FILES | wxDIR_HIDDEN );
102 wxString ext = wxS(
"" );
104 int idx = filenameStr.Find(
'.',
true );
107 ext = filenameStr.Mid( idx + 1 ).MakeLower();
109 if( lowerExts.count( ext ) )
112 cont = dir.GetNext( &filenameStr );
virtual bool DeleteLibrary(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr)
Delete an existing library and returns true, or if library does not exist returns false,...
virtual void GetLibraryOptions(STRING_UTF8_MAP *aListToAppendTo) const
Append supported IO options to aListToAppenTo along with internationalized descriptions.
virtual const IO_FILE_DESC GetLibraryDesc() const =0
Get the descriptor for the library container that this IO plugin operates on.
virtual void CreateLibrary(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr)
Create a new empty library at aLibraryPath empty.
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.
A name/value tuple with unique names and optional values.
#define NOT_IMPLEMENTED(aCaller)
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.