Subversion Repositories Kolibri OS

Rev

Rev 8622 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8622 Rev 8624
1
#include 
1
#include 
-
 
2
#include 
-
 
3
#include 
2
 
4
 
3
int fgetc(FILE* stream)
5
int fgetc(FILE* stream)
4
{
6
{
-
 
7
    unsigned bytes_read;
5
    int c, rc;
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;
6
    rc = fread(&c, sizeof(char), 1, stream);
30
                stream->error = errno;
-
 
31
                break;
7
    if(rc<1){
32
        }
8
        return EOF;
33
        return EOF;
9
    }
34
    }
-
 
35
 
-
 
36
    stream->position++;
10
    return c;
37
    return c;
11
}
38
}
12
>
-