Don't crash in wxFFile::Eof() and Error() if file is closed

Assert and return false instead, this is more developer-friendly.

Add unit tests to check that these functions really work as expected when
called on a closed file.

Closes #17828.
This commit is contained in:
jprotopopov
2017-04-01 18:38:14 +02:00
committed by Vadim Zeitlin
parent a05b1f39f5
commit 9b1afaa7a6
5 changed files with 79 additions and 11 deletions

View File

@@ -76,13 +76,13 @@ public:
wxFileOffset Length() const;
// simple accessors: note that Eof() and Error() may only be called if
// IsOpened()!
// IsOpened(). Otherwise they assert and return false.
// is file opened?
bool IsOpened() const { return m_fp != NULL; }
// is end of file reached?
bool Eof() const { return feof(m_fp) != 0; }
bool Eof() const;
// has an error occurred?
bool Error() const { return ferror(m_fp) != 0; }
bool Error() const;
// get the file name
const wxString& GetName() const { return m_name; }
// type such as disk or pipe