Skip to content

Commit

Permalink
Don't throw error when reading empty file
Browse files Browse the repository at this point in the history
Clear out buffer when reading files
  • Loading branch information
Blake-Madden committed May 31, 2024
1 parent cee8411 commit ec0ffa6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/util/textstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ namespace Wisteria
bool TextStream::ReadFile(wxString& filePath, wxString& textBuffer,
const wxString& srcCharSet /*= wxString{}*/)
{
textBuffer.clear();
// can't do anything with an empty path, even prompting the user
// won't make any sense
if (filePath.empty())
Expand Down Expand Up @@ -315,6 +316,11 @@ namespace Wisteria
return false;
}
}
// empty file's are OK, just silently return
catch (MemoryMappedFileEmptyException&)
{
return true;
}
catch (...)
{
wxFile theFile;
Expand Down

0 comments on commit ec0ffa6

Please sign in to comment.