diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index cd73938c58..642b82fb15 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -47,6 +47,7 @@ #include #include #include +#include //#define USE_SCH_LEGACY_IO_PLUGIN @@ -315,30 +316,13 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in delete g_RootSheet; // Delete the current project. g_RootSheet = NULL; // Force CreateScreens() to build new empty project on load failure. - // Open file and guess at filetype Kicad/Eagle - wxTextFile tempFile; - tempFile.Open( fullFileName ); - wxString firstline; - // read the first line - firstline = tempFile.GetFirstLine(); - tempFile.Close(); + SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) ); - SCH_IO_MGR::SCH_FILE_T filetype; - - if( firstline.StartsWith( "CheckHeader( fullFileName ) ) { - filetype = SCH_IO_MGR::SCH_EAGLE; + pi.set( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_EAGLE ) ); } - else if( firstline.StartsWith( "(schematic" ) ) - { - filetype = SCH_IO_MGR::SCH_KICAD; - } - else - { - filetype = SCH_IO_MGR::SCH_LEGACY; - } - - SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( filetype ) ); try { diff --git a/eeschema/sch_eagle_plugin.cpp b/eeschema/sch_eagle_plugin.cpp index e8a93e17e9..7b2d8019e0 100644 --- a/eeschema/sch_eagle_plugin.cpp +++ b/eeschema/sch_eagle_plugin.cpp @@ -835,6 +835,21 @@ LIB_TEXT* SCH_EAGLE_PLUGIN::loadSymboltext( LIB_PART* aPart, wxXmlNode* aLibText } +bool SCH_EAGLE_PLUGIN::CheckHeader( const wxString& aFileName ) +{ + // Open file and check first line + wxTextFile tempFile; + + tempFile.Open( aFileName ); + wxString firstline; + // read the first line + firstline = tempFile.GetFirstLine(); + tempFile.Close(); + + return firstline.StartsWith( "------------------------------------------------ diff --git a/eeschema/sch_legacy_plugin.cpp b/eeschema/sch_legacy_plugin.cpp index c73dad3746..b7daee5ecd 100644 --- a/eeschema/sch_legacy_plugin.cpp +++ b/eeschema/sch_legacy_plugin.cpp @@ -3604,5 +3604,19 @@ void SCH_LEGACY_PLUGIN::SaveLibrary( const wxString& aLibraryPath, const PROPERT } +bool SCH_LEGACY_PLUGIN::CheckHeader( const wxString& aFileName ) +{ + // Open file and check first line + wxTextFile tempFile; + + tempFile.Open( aFileName ); + wxString firstline; + // read the first line + firstline = tempFile.GetFirstLine(); + tempFile.Close(); + + return firstline.StartsWith( "EESchema" ); +} + const char* SCH_LEGACY_PLUGIN::PropBuffering = "buffering"; const char* SCH_LEGACY_PLUGIN::PropNoDocFile = "no_doc_file"; diff --git a/eeschema/sch_legacy_plugin.h b/eeschema/sch_legacy_plugin.h index 8f15376d7b..2d4f8ba383 100644 --- a/eeschema/sch_legacy_plugin.h +++ b/eeschema/sch_legacy_plugin.h @@ -124,6 +124,8 @@ public: const PROPERTIES* aProperties = NULL ) override; void SaveLibrary( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL ) override; + bool CheckHeader(const wxString& aFileName) override; + private: void loadHierarchy( SCH_SHEET* aSheet ); void loadHeader( FILE_LINE_READER& aReader, SCH_SCREEN* aScreen ); diff --git a/eeschema/sch_plugin.cpp b/eeschema/sch_plugin.cpp index 7b859ea272..fac5ae3f5e 100644 --- a/eeschema/sch_plugin.cpp +++ b/eeschema/sch_plugin.cpp @@ -188,3 +188,11 @@ void SCH_PLUGIN::SymbolLibOptions( PROPERTIES* aListToAppendTo ) const ) ); #endif } + + +bool SCH_PLUGIN::CheckHeader( const wxString& aFileName ) +{ + // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface. + not_implemented( this, __FUNCTION__ ); + return NULL; +}