libc: Make fread/fwrite return the number of items read/written instead of the number of bytes

This commit is contained in:
apio 2022-11-06 14:46:22 +01:00
parent d7692a7f59
commit 40b078e0a2

View File

@ -136,7 +136,7 @@ extern "C"
return 0;
}
if (status == 0) stream->f_eof = 1;
return (size_t)status;
return (size_t)status / size;
}
char* fgets(char* buf, int size, FILE* stream)
@ -257,9 +257,7 @@ extern "C"
long ftell(FILE* stream)
{
return lseek(stream->f_fd, 0,
SEEK_CUR); // FIXME: Store the last seeked position in the file struct to avoid redundant syscalls
// maybe? We'd have to update this value in fread() and fwrite() as well...
return lseek(stream->f_fd, 0, SEEK_CUR);
}
off_t ftello(FILE* stream)
@ -290,7 +288,7 @@ extern "C"
return 0;
}
if (status == 0) stream->f_eof = 1;
return (size_t)status;
return (size_t)status / size;
}
void setbuf(FILE*, char*)