mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-13 17:53:11 +02:00
On Linux you can fopen (read) a directory for no reason, fix SafeReadFile to make it safer
TIL
This commit is contained in:
parent
157180e772
commit
883a1f8d97
@ -95,6 +95,12 @@ std::string StrPrintf( const char* format, ... )
|
||||
|
||||
wxString SafeReadFile( const wxString& aFilePath, const wxString& aReadType )
|
||||
{
|
||||
// Check the path exists as a file first
|
||||
// the IsOpened check would be logical, but on linux you can fopen (in read mode) a directory
|
||||
// And then everything else in here will barf
|
||||
if( !wxFileExists( aFilePath ) )
|
||||
THROW_IO_ERROR( wxString::Format( _( "File '%s' does not exist." ), aFilePath ) );
|
||||
|
||||
wxString contents;
|
||||
wxFFile ff( aFilePath );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user