io: Always discard file_ pointer on close()

This commit is contained in:
Eidolon 2024-02-20 01:26:00 -06:00
parent 6f2a73e911
commit a5b870a0b3

View file

@ -157,14 +157,12 @@ void FileStream::close()
if (std::fclose((std::FILE*)(this->file_)) != 0)
{
// The FILE is now invalid even though fclose failed.
// There is nothing we can do but abandon the pointer.
file_ = nullptr;
int err = errno;
throw make_exception_from_errno(err);
}
if (std::ferror((std::FILE*)(this->file_)) != 0)
{
int err = errno;
throw make_exception_from_errno(err);
}
file_ = nullptr;
}