forked from KolibriOS/kolibrios
Magomed Kostoev (mkostoevr)
1f4d74f500
git-svn-id: svn://kolibrios.org@8622 a494cfbc-eb01-0410-851d-a64ba20cac60
17 lines
519 B
C
17 lines
519 B
C
#include <stdio.h>
|
|
|
|
size_t fread(void *restrict ptr, size_t size, size_t nmemb, FILE *restrict stream) {
|
|
unsigned bytes_read = 0;
|
|
unsigned bytes_count = size * nmemb;
|
|
_ksys_file_read_file(stream->name, stream->position, bytes_count, ptr, &bytes_read);
|
|
stream->position += bytes_read;
|
|
ksys_bdfe_t info;
|
|
// TODO: Handle _ksys_file_get_info error somehow
|
|
if (!_ksys_file_get_info(stream->name, &info)) {
|
|
if (stream->position >= info.size) {
|
|
stream->eof = 1;
|
|
}
|
|
}
|
|
return bytes_read / size;
|
|
}
|