stream: fix cache flush when stream is at EOF
Signed-off-by: Simon Rozman <simon.rozman@amebis.si>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user