Commit 9ae4e609 authored by Dick Hollenbeck's avatar Dick Hollenbeck

start using FILE_LINE_READER( const wxString& )

parent 98086a88
......@@ -222,16 +222,8 @@ void FP_CACHE::Load()
do
{
FILE* fp = wxFopen( fpFileName, wxT( "r" ) );
if( !fp )
{
THROW_IO_ERROR( wxString::Format( _( "cannot open footprint library file '%s'" ),
fpFileName.GetData() ) );
}
// reader now owns fp, will close on exception or return
FILE_LINE_READER reader( fp, fpFileName );
FILE_LINE_READER reader( fpFileName );
m_owner->m_parser->SetLineReader( &reader );
......@@ -1551,15 +1543,7 @@ PCB_IO::~PCB_IO()
BOARD* PCB_IO::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* aProperties )
{
wxFFile file( aFileName, wxT("r") );
if( !file.IsOpened() )
{
wxString msg = wxString::Format( _( "Unable to read file \"%s\"" ), GetChars( aFileName ) );
THROW_IO_ERROR( msg );
}
FILE_LINE_READER reader( file.fp(), aFileName, false /* wxFFile owns fp */ );
FILE_LINE_READER reader( aFileName );
m_parser->SetLineReader( &reader );
m_parser->SetBoard( aAppendToMe );
......
......@@ -238,15 +238,7 @@ BOARD* LEGACY_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPE
// delete on exception, iff I own m_board, according to aAppendToMe
auto_ptr<BOARD> deleter( aAppendToMe ? NULL : m_board );
FILE* fp = wxFopen( aFileName, wxT( "r" ) );
if( !fp )
{
m_error.Printf( _( "Unable to open file '%s'" ), aFileName.GetData() );
THROW_IO_ERROR( m_error );
}
// reader now owns fp, will close on exception or return
FILE_LINE_READER reader( fp, aFileName );
FILE_LINE_READER reader( aFileName );
m_reader = &reader; // member function accessibility
......@@ -3920,15 +3912,7 @@ wxDateTime FPL_CACHE::GetLibModificationTime()
void FPL_CACHE::Load()
{
FILE* fp = wxFopen( m_lib_name, wxT( "r" ) );
if( !fp )
{
THROW_IO_ERROR( wxString::Format(
_( "Unable to open legacy library file '%s'" ), m_lib_name.GetData() ) );
}
// reader now owns fp, will close on exception or return
FILE_LINE_READER reader( fp, m_lib_name );
FILE_LINE_READER reader( m_lib_name );
ReadAndVerifyHeader( &reader );
SkipIndex( &reader );
......
......@@ -230,14 +230,9 @@ void SPECCTRA_DB::readTIME( time_t* time_stamp ) throw( IO_ERROR )
void SPECCTRA_DB::LoadPCB( const wxString& filename ) throw( IO_ERROR )
{
FILE* fp = wxFopen( filename, wxT("r") );
FILE_LINE_READER reader( filename );
if( !fp )
{
ThrowIOError( _("Unable to open file \"%s\""), GetChars(filename) );
}
PushReader( new FILE_LINE_READER( fp, filename ) );
PushReader( &reader );
if( NextTok() != T_LEFT )
Expecting( T_LEFT );
......@@ -248,21 +243,15 @@ void SPECCTRA_DB::LoadPCB( const wxString& filename ) throw( IO_ERROR )
SetPCB( new PCB() );
doPCB( pcb );
delete PopReader(); // close fp
PopReader();
}
void SPECCTRA_DB::LoadSESSION( const wxString& filename ) throw( IO_ERROR )
{
FILE* fp = wxFopen( filename, wxT("r") );
if( !fp )
{
ThrowIOError( _("Unable to open file \"%s\""), GetChars(filename) );
}
FILE_LINE_READER reader( filename );
PushReader( new FILE_LINE_READER( fp, filename ) );
PushReader( &reader );
if( NextTok() != T_LEFT )
Expecting( T_LEFT );
......@@ -274,7 +263,7 @@ void SPECCTRA_DB::LoadSESSION( const wxString& filename ) throw( IO_ERROR )
doSESSION( session );
delete PopReader(); // close fp
PopReader();
}
......
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