Rev 145 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
145 | halyavin | 1 | #include "stdio.h" |
2 | int fputc(int c,FILE* file) |
||
3 | { |
||
610 | andrew_pro | 4 | dword res; |
5 | |||
6 | if ((file->mode & 3)==FILE_OPEN_READ) return EOF; |
||
7 | |||
8 | file->buffer[0]=c; |
||
145 | halyavin | 9 | if ((file->mode & 3)==FILE_OPEN_APPEND) |
610 | andrew_pro | 10 | { |
145 | halyavin | 11 | file->filepos=file->filesize; |
610 | andrew_pro | 12 | file->filesize++; |
13 | res=_ksys_appendtofile(file->filename,file->filepos,1,file->buffer); |
||
14 | if (res!=0) return(res); |
||
15 | file->filepos++; |
||
16 | return(0); |
||
17 | } |
||
18 | if ((file->mode & 3)==FILE_OPEN_WRITE) |
||
145 | halyavin | 19 | { |
610 | andrew_pro | 20 | if (file->filepos==0) |
21 | { //file not craeted |
||
22 | res=_ksys_rewritefile(file->filename,1,file->buffer); |
||
23 | if (res!=0) return(res); |
||
24 | file->filepos++; |
||
25 | return 0; |
||
145 | halyavin | 26 | } |
610 | andrew_pro | 27 | else |
28 | { //file craeted and need append one byte |
||
29 | res=_ksys_appendtofile(file->filename,file->filepos,1,file->buffer); |
||
30 | if (res!=0) return(res); |
||
31 | file->filepos++; |
||
32 | return 0; |
||
33 | } |
||
145 | halyavin | 34 | } |
35 | } |