Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 5b7aec5

Browse files
author
Ian Macphail
committed
[[ Bug 23055 ]] Reset EOF marker when seeking in a file on macOS
This patch fixes an issue where if a previous read from a filehandle has resulted in an END-OF-FILE then subsequent reads would always fail with EOF result even after seeking to another location within the file. This is fixed by resetting the error state of the filehandle before seeking.
1 parent 43df7c4 commit 5b7aec5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

engine/src/dskmac.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,6 +1601,11 @@ class MCStdioFileHandle: public MCSystemFileHandle
16011601
virtual bool Seek(int64_t offset, int p_dir)
16021602
{
16031603
// TODO Add MCSystemFileHandle::SetStream(char *newptr) ?
1604+
if (m_is_eof)
1605+
{
1606+
clearerr(m_stream);
1607+
m_is_eof = false;
1608+
}
16041609
return fseeko(m_stream, offset, p_dir < 0 ? SEEK_END : (p_dir > 0 ? SEEK_SET : SEEK_CUR)) == 0;
16051610
}
16061611

0 commit comments

Comments
 (0)