Subversion Repositories Kolibri OS

Rev

Rev 8622 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
8622 Boppan 1
#include 
8624 Boppan 2
#include 
3
#include 
8622 Boppan 4
 
5
int fgetc(FILE* stream)
6
{
8624 Boppan 7
    unsigned bytes_read;
8
    char c;
9
 
10
    unsigned status = _ksys_file_read_file(stream->name, stream->position, 1, &c, &bytes_read);
11
 
12
    if (status != _KOS_FS_ERR_SUCCESS) {
13
        switch (status) {
14
            case _KOS_FS_ERR_EOF:
15
                stream->eof = 1;
16
                break;
17
            case _KOS_FS_ERR_1:
18
            case _KOS_FS_ERR_2:
19
            case _KOS_FS_ERR_3:
20
            case _KOS_FS_ERR_4:
21
            case _KOS_FS_ERR_5:
22
            case _KOS_FS_ERR_7:
23
            case _KOS_FS_ERR_8:
24
            case _KOS_FS_ERR_9:
25
            case _KOS_FS_ERR_10:
26
            case _KOS_FS_ERR_11:
27
            default:
28
                // Just some IO error, who knows what exactly happened
29
                errno = EIO;
30
                stream->error = errno;
31
                break;
32
        }
8622 Boppan 33
        return EOF;
34
    }
8624 Boppan 35
 
36
    stream->position++;
8622 Boppan 37
    return c;
38
}