diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 1a5db21701..e9f8b8838b 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -715,7 +715,7 @@ void SCH_EDIT_FRAME::OnImportProject( wxCommandEvent& aEvent ) const IO_BASE::IO_FILE_DESC& desc = pi->GetSchematicFileDesc(); - if( desc.m_FileExtensions.empty() ) + if( desc.m_FileExtensions.empty() || !desc.m_CanRead ) continue; if( !fileFiltersStr.IsEmpty() ) diff --git a/include/io/io_base.h b/include/io/io_base.h index 0263ceb677..78640eca17 100644 --- a/include/io/io_base.h +++ b/include/io/io_base.h @@ -41,12 +41,15 @@ public: std::vector m_FileExtensions; ///< Filter used for file pickers if m_IsFile is true std::vector m_ExtensionsInDir; ///< In case of folders: extensions of files inside bool m_IsFile; ///< Whether the library is a folder or a file + bool m_CanRead; ///< Whether the IO can read this file type + bool m_CanWrite; ///< Whether the IO can write this file type IO_FILE_DESC( const wxString& aDescription, const std::vector& aFileExtensions, - const std::vector& aExtsInFolder = {}, bool aIsFile = true ) : + const std::vector& aExtsInFolder = {}, bool aIsFile = true, + bool aCanRead = true, bool aCanWrite = true ) : m_Description( aDescription ), m_FileExtensions( aFileExtensions ), m_ExtensionsInDir( aExtsInFolder ), - m_IsFile( aIsFile ) + m_IsFile( aIsFile ), m_CanRead( aCanRead ), m_CanWrite( aCanWrite ) { } diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 426cd291f5..e37d925e19 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -112,7 +112,7 @@ bool AskLoadBoardFileName( PCB_EDIT_FRAME* aParent, wxString* aFileName, int aCt const IO_BASE::IO_FILE_DESC& desc = pi->GetBoardFileDesc(); - if( desc.m_FileExtensions.empty() ) + if( desc.m_FileExtensions.empty() || !desc.m_CanRead ) continue; descriptions.emplace_back( desc ); diff --git a/pcbnew/pcb_io/ipc2581/pcb_io_ipc2581.h b/pcbnew/pcb_io/ipc2581/pcb_io_ipc2581.h index a2317736ea..89261d89ac 100644 --- a/pcbnew/pcb_io/ipc2581/pcb_io_ipc2581.h +++ b/pcbnew/pcb_io/ipc2581/pcb_io_ipc2581.h @@ -85,7 +85,7 @@ public: const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const override { - return IO_BASE::IO_FILE_DESC( wxEmptyString, {} ); + return IO_BASE::IO_FILE_DESC( wxEmptyString, {}, {}, false, false, true ); } const IO_BASE::IO_FILE_DESC GetLibraryDesc() const override