Mercurial > hg > Members > ikki > CbC_log
view wc_sigos/UnixFileImpl.cpp @ 5:7599728af8ba default tip
add wc
author | ichikitakahiro <e165713@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 19 Jun 2021 07:24:43 +0900 |
parents | |
children |
line wrap: on
line source
#include <stdio.h> #impl UnixFileImp as "UnixFileImpl.h" File* createUnixFileImpl(struct Context* context) { File *file = new File(); file->FileImpl = (union Data*)new FileImpl(); return file; } readBlock(UnixFileImpl* file) { Block *block = new Block(); int len = read(fd, BUFSIZE, block->data); block->eof &= ~BLOCK_FLAG_EOF; if (len <=0 ) { block->eof |= BLOCK_FLAG_EOF; close(file->fd); } return block ; } __code unixOpen(UnixFileImpl* file,Key *key, __code next(Block *block,...)); file->fd = open(key->path,unix_mode(key->modde)); if (fd < 0) { goto error("can't open"); } goto next(readBlock(file), ...); } __code uniAck(UnixFileImpl* file,Ack *ack, __code next(Block *block,...)); if (!ack->isOk) { close(file->fd); goto next(...); } goto next(readBlock(file), ...); // file is automaticaly put into local dataGearManger/input }