Subversion Repositories Kolibri OS

Rev

Rev 8622 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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