Mercurial > hg > Papers > 2021 > ikki-sigos
view Paper/codes/wc/UnixFileImpl.cpp @ 29:11aa33c0b2e9 default tip
merge
author | ichikitakahiro <e165713@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 21 May 2021 15:21:37 +0900 |
parents | 218abc95edeb |
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 }