Implement stdio buffering #36

Merged
apio merged 7 commits from stdio-buffers into main 2023-07-22 09:39:02 +00:00
Showing only changes of commit 19b4aa9f81 - Show all commits

View File

@ -350,6 +350,8 @@ extern "C"
int fseek(FILE* stream, long offset, int whence)
{
fflush(stream);
long result = lseek(stream->_fd, offset, whence);
if (result < 0) return -1;
@ -361,11 +363,15 @@ extern "C"
long ftell(FILE* stream)
{
fflush(stream);
return lseek(stream->_fd, 0, SEEK_CUR);
}
void rewind(FILE* stream)
{
fflush(stream);
lseek(stream->_fd, 0, SEEK_SET);
clearerr(stream);
@ -383,6 +389,8 @@ extern "C"
int fsetpos(FILE* stream, const fpos_t* pos)
{
fflush(stream);
return fseek(stream, *pos, SEEK_SET);
}