/programs/develop/ktcc/trunk/libc.obj/source/stdio/fread.c |
---|
12,6 → 12,12 |
return 0; |
} |
if(size<=0 || nmemb<=0){ |
errno = EINVAL; |
stream->error=errno; |
return 0; |
} |
if(stream==stdin){ |
con_init(); |
con_gets((char*)ptr, bytes_count+1); |
25,14 → 31,17 |
//debug_printf("Ungetc: %x\n", ((char*) ptr)[0]); |
} |
unsigned status = _ksys_file_read_file(stream->name, stream->position, bytes_count, ptr , &bytes_read); |
if (status) { |
if (status != KSYS_FS_ERR_SUCCESS) { |
if(status == KSYS_FS_ERR_EOF){ |
stream->eof=1; |
}else{ |
errno = EIO; |
stream->error = errno; |
return 0; |
}else { |
} |
} |
stream->position+=bytes_read; |
} |
} |
return bytes_read/size; |
} |
return bytes_read; |
} |
/programs/develop/ktcc/trunk/libc.obj/source/stdio/fwrite.c |
---|
12,18 → 12,26 |
return 0; |
} |
if(size<=0 || nmemb<=0){ |
errno = EINVAL; |
stream->error=errno; |
return 0; |
} |
if(stream==stdout){ |
con_init(); |
con_write_string((char*)ptr, bytes_count); |
return nmemb; |
} |
else if(stream==stderr){ |
if(stream==stderr){ |
for (size_t i = 0; i < bytes_count; i++) { |
char c = *(char*)(ptr+i); |
_ksys_debug_putc(c); |
} |
return nmemb; |
} |
else{ |
if(stream->mode != _FILEMODE_R){ |
unsigned status = _ksys_file_write_file(stream->name, stream->position, bytes_count, ptr, &bytes_written); |
if (status != KSYS_FS_ERR_SUCCESS) { |
30,10 → 38,8 |
errno = EIO; |
stream->error = errno; |
return 0; |
}else { |
} |
stream->position+=bytes_written; |
} |
return bytes_written/size; |
} |
} |
return bytes_written; |
} |