Use CheckFileHeader in CADSTAR_SCH_ARCHIVE_PLUGIN::CanReadLibrary
This commit is contained in:
parent
09f1df6c94
commit
5ccdb75091
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include <sch_plugins/cadstar/cadstar_sch_archive_loader.h>
|
#include <sch_plugins/cadstar/cadstar_sch_archive_loader.h>
|
||||||
#include <sch_plugins/cadstar/cadstar_sch_archive_plugin.h>
|
#include <sch_plugins/cadstar/cadstar_sch_archive_plugin.h>
|
||||||
|
#include <plugins/cadstar/cadstar_parts_lib_parser.h>
|
||||||
|
|
||||||
#include <lib_symbol.h>
|
#include <lib_symbol.h>
|
||||||
#include <progress_reporter.h>
|
#include <progress_reporter.h>
|
||||||
|
@ -53,24 +54,14 @@ bool CADSTAR_SCH_ARCHIVE_PLUGIN::CanReadLibrary( const wxString& aFileName ) con
|
||||||
if( !SCH_PLUGIN::CanReadLibrary( aFileName ) )
|
if( !SCH_PLUGIN::CanReadLibrary( aFileName ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
wxFFileInputStream input( aFileName );
|
try
|
||||||
|
{
|
||||||
if( !input.IsOk() || input.Eof() )
|
CADSTAR_PARTS_LIB_PARSER p;
|
||||||
return false;
|
return p.CheckFileHeader( aFileName.fn_str() );
|
||||||
|
}
|
||||||
// Find first non-empty line
|
catch( const std::runtime_error& )
|
||||||
wxTextInputStream text( input );
|
{
|
||||||
wxString line = text.ReadLine();
|
}
|
||||||
|
|
||||||
while( !input.Eof() && line.IsEmpty() )
|
|
||||||
line = text.ReadLine().Trim( false /*trim from left*/ );
|
|
||||||
|
|
||||||
// CADSTAR libs start with
|
|
||||||
// # FORMAT 32
|
|
||||||
// or
|
|
||||||
// .PartName :2 ;Part 0 Description
|
|
||||||
if( line.StartsWith( wxS( "#" ) ) || line.StartsWith( wxS( "." ) ) )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue