stream: fix cache flush when stream is at EOF

Signed-off-by: Simon Rozman <simon.rozman@amebis.si>
This commit is contained in:
2025-12-18 13:27:37 +01:00
parent 97e781778c
commit 83fa108f99

View File

@@ -1816,8 +1816,7 @@ namespace stdex
void init(_Inout_ basic_file& source)
{
m_source = &source;
m_state = m_source->state();
if (m_source->ok()) {
if ((m_state = m_source->state()) != state_t::fail) {
m_offset = m_source->tell();
#if SET_FILE_OP_TIMES
m_atime = m_source->atime();
@@ -1828,7 +1827,7 @@ namespace stdex
void done()
{
if (m_source && m_source->ok()) {
if (m_source && m_source->state() != state_t::fail) {
flush_cache();
if (!ok()) _Unlikely_
throw std::system_error(sys_error(), std::system_category(), "failed to flush cache"); // Data loss occurred