Rev 145 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
610 | andrew_pro | 1 | #include |
2 | #include |
||
3 | |||
4 | int fwrite(void *buffer,int size,int count,FILE* file) |
||
145 | halyavin | 5 | { |
610 | andrew_pro | 6 | dword res; |
7 | dword fullsize; |
||
8 | |||
9 | if ((file->mode & 3==FILE_OPEN_READ) && (file->mode & FILE_OPEN_PLUS==0)) return 0; |
||
10 | |||
145 | halyavin | 11 | if (file->mode & 3==FILE_OPEN_APPEND) |
12 | file->filepos=file->filesize; |
||
610 | andrew_pro | 13 | fullsize=count*size; |
14 | |||
15 | if ((file->filesize)<(file->filepos+fullsize)) file->filesize=file->filepos+fullsize; |
||
16 | |||
17 | if (file->mode & 3==FILE_OPEN_APPEND) |
||
145 | halyavin | 18 | { |
610 | andrew_pro | 19 | file->filepos==file->filesize; |
20 | res=_ksys_appendtofile(file->filename,file->filepos,fullsize,buffer); |
||
21 | if (res==0) |
||
22 | { |
||
23 | file->filepos+=fullsize; |
||
24 | fullsize=fullsize/size; |
||
25 | return(fullsize); |
||
26 | } |
||
27 | else return(0); |
||
28 | |||
145 | halyavin | 29 | } |
610 | andrew_pro | 30 | |
31 | if (file->mode & 3==FILE_OPEN_WRITE) |
||
32 | { |
||
33 | if (file->filepos==0) |
||
34 | { //file mot craeted yet |
||
35 | res=_ksys_rewritefile(file->filename,fullsize,buffer); |
||
36 | if (res==0) |
||
37 | { |
||
38 | file->filepos+=fullsize; |
||
39 | fullsize=fullsize/count; |
||
40 | return(fullsize); |
||
41 | } |
||
42 | else return(0); |
||
43 | } |
||
44 | else |
||
45 | { |
||
46 | res=_ksys_appendtofile(file->filename,file->filepos,fullsize,buffer); |
||
47 | if (res==0) |
||
48 | { |
||
49 | file->filepos+=fullsize; |
||
50 | fullsize=fullsize/count; |
||
51 | return(fullsize); |
||
52 | } |
||
53 | else return(0); |
||
54 | } |
||
55 | } |
||
56 | else return(0); |
||
145 | halyavin | 57 | }(file-> |