Use buffered file io; use fn_str() more.
This commit is contained in:
parent
5ccdb75091
commit
e35174d64b
|
@ -36,20 +36,9 @@ public:
|
|||
|
||||
bool CheckFileHeader( const std::filesystem::path& aPath ) const;
|
||||
|
||||
bool CheckFileHeader( const std::string& aPath ) const
|
||||
{
|
||||
return CheckFileHeader( std::filesystem::path( aPath ) );
|
||||
};
|
||||
|
||||
|
||||
CADSTAR_PARTS_LIB_MODEL ReadContent( const std::string& aSource ) const;
|
||||
|
||||
CADSTAR_PARTS_LIB_MODEL ReadFile( const std::filesystem::path& aPath ) const;
|
||||
|
||||
CADSTAR_PARTS_LIB_MODEL ReadFile( const std::string& aPath ) const
|
||||
{
|
||||
return ReadFile( std::filesystem::path( aPath ) );
|
||||
};
|
||||
};
|
||||
|
||||
#endif //CADSTAR_PARTS_LIB_PARSER_H
|
||||
|
|
|
@ -29,9 +29,10 @@
|
|||
namespace PLUGIN_UTILS
|
||||
{
|
||||
|
||||
bool fileStartsWithPrefix( const wxString& aFilePath, const wxString& aPrefix, bool aIgnoreWhitespace )
|
||||
bool fileStartsWithPrefix( const wxString& aFilePath, const wxString& aPrefix,
|
||||
bool aIgnoreWhitespace )
|
||||
{
|
||||
wxFileInputStream input( aFilePath );
|
||||
wxFFileInputStream input( aFilePath );
|
||||
|
||||
if( input.IsOk() && !input.Eof() )
|
||||
{
|
||||
|
@ -41,7 +42,7 @@ bool fileStartsWithPrefix( const wxString& aFilePath, const wxString& aPrefix, b
|
|||
|
||||
if( aIgnoreWhitespace )
|
||||
{
|
||||
while( line.IsEmpty() )
|
||||
while( !input.Eof() && line.IsEmpty() )
|
||||
line = text.ReadLine().Trim( false /*trim from left*/ );
|
||||
}
|
||||
|
||||
|
@ -55,7 +56,7 @@ bool fileStartsWithPrefix( const wxString& aFilePath, const wxString& aPrefix, b
|
|||
|
||||
bool fileStartsWithBinaryHeader( const wxString& aFilePath, const std::vector<uint8_t>& aHeader )
|
||||
{
|
||||
wxFileInputStream input( aFilePath );
|
||||
wxFFileInputStream input( aFilePath );
|
||||
|
||||
if( input.IsOk() && !input.Eof() )
|
||||
{
|
||||
|
|
|
@ -67,12 +67,12 @@ std::vector<LIB_SYMBOL*> CADSTAR_SCH_ARCHIVE_LOADER::LoadPartsLib( const wxStrin
|
|||
|
||||
CADSTAR_PARTS_LIB_PARSER p;
|
||||
|
||||
if( !p.CheckFileHeader( aFilename.utf8_string() ) )
|
||||
if( !p.CheckFileHeader( aFilename.fn_str() ) )
|
||||
THROW_IO_ERROR(
|
||||
_( "The selected file does not appear to be a CADSTAR parts Library file" ) );
|
||||
|
||||
// TODO: we could add progress reporting for reading .lib
|
||||
CADSTAR_PARTS_LIB_MODEL csLib = p.ReadFile( aFilename.utf8_string() );
|
||||
CADSTAR_PARTS_LIB_MODEL csLib = p.ReadFile( aFilename.fn_str() );
|
||||
|
||||
if( m_progressReporter )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue