Commit b66d6e2d authored by Alexander Lunev's avatar Alexander Lunev Committed by Dick Hollenbeck

pcad2kicadpcb: check for file format

parent e513380a
...@@ -34,9 +34,11 @@ ...@@ -34,9 +34,11 @@
namespace PCAD2KICAD { namespace PCAD2KICAD {
static KEYWORD empty_keywords[1] = {}; static KEYWORD empty_keywords[1] = {};
static const char ACCEL_ASCII_KEYWORD[] = "ACCEL_ASCII";
void LoadInputFile( wxString aFileName, wxXmlDocument* aXmlDoc ) void LoadInputFile( wxString aFileName, wxXmlDocument* aXmlDoc )
{ {
char line[sizeof( ACCEL_ASCII_KEYWORD )];
int tok; int tok;
XNODE* iNode = NULL, *cNode = NULL; XNODE* iNode = NULL, *cNode = NULL;
wxString str, propValue, content; wxString str, propValue, content;
...@@ -47,6 +49,14 @@ void LoadInputFile( wxString aFileName, wxXmlDocument* aXmlDoc ) ...@@ -47,6 +49,14 @@ void LoadInputFile( wxString aFileName, wxXmlDocument* aXmlDoc )
if( !fp ) if( !fp )
THROW_IO_ERROR( wxT( "Unable to open file: " ) + aFileName ); THROW_IO_ERROR( wxT( "Unable to open file: " ) + aFileName );
// check file format
if( !fgets( line, sizeof( line ), fp )
|| strcmp( line, ACCEL_ASCII_KEYWORD ) )
THROW_IO_ERROR( "Unknown file type" );
// rewind the file
fseek( fp, 0, SEEK_SET );
// lexer now owns fp, will close on exception or return // lexer now owns fp, will close on exception or return
DSNLEXER lexer( empty_keywords, 0, fp, aFileName ); DSNLEXER lexer( empty_keywords, 0, fp, aFileName );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment