Rev 6433 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
647 | andrew_pro | 1 | #include |
2 | #include |
||
3 | |||
4 | int fread(void *buffer,int size,int count,FILE* file) |
||
5 | { |
||
6 | dword res; |
||
7 | dword fullsize; |
||
8 | |||
6433 | siemargl | 9 | if(!file || !buffer) |
10 | { |
||
11 | errno = E_INVALIDPTR; |
||
12 | return 0; |
||
13 | } |
||
647 | andrew_pro | 14 | |
7172 | siemargl | 15 | if ((file->mode &3)!=FILE_OPEN_READ && (file->mode & FILE_OPEN_PLUS)==0) |
6433 | siemargl | 16 | { |
17 | errno = E_ACCESS; |
||
18 | return 0; |
||
19 | } |
||
20 | |||
647 | andrew_pro | 21 | fullsize=count*size; |
6433 | siemargl | 22 | if ((fullsize+file->filepos)>=(file->filesize)) |
647 | andrew_pro | 23 | { |
24 | fullsize=file->filesize-file->filepos; |
||
25 | if (fullsize<=0) return(0); |
||
26 | } |
||
27 | |||
28 | res=_ksys_readfile(file->filename,file->filepos,fullsize,buffer); |
||
29 | if (res==0) |
||
6433 | siemargl | 30 | { |
647 | andrew_pro | 31 | file->filepos=file->filepos+fullsize; |
32 | fullsize=fullsize/size; |
||
33 | return(fullsize); |
||
34 | } |
||
6433 | siemargl | 35 | else |
36 | { |
||
37 | errno = -res; |
||
38 | return 0; |
||
39 | } |
||
40 | }=0)> |