Mercurial > hg > Members > ikki > CbC_log
comparison 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 |
comparison
equal
deleted
inserted
replaced
4:d6911fe00127 | 5:7599728af8ba |
---|---|
1 #include <stdio.h> | |
2 #impl UnixFileImp as "UnixFileImpl.h" | |
3 | |
4 | |
5 File* createUnixFileImpl(struct Context* context) { | |
6 File *file = new File(); | |
7 file->FileImpl = (union Data*)new FileImpl(); | |
8 return file; | |
9 } | |
10 | |
11 readBlock(UnixFileImpl* file) { | |
12 Block *block = new Block(); | |
13 int len = read(fd, BUFSIZE, block->data); | |
14 block->eof &= ~BLOCK_FLAG_EOF; | |
15 if (len <=0 ) { | |
16 block->eof |= BLOCK_FLAG_EOF; | |
17 close(file->fd); | |
18 } | |
19 return block ; | |
20 } | |
21 | |
22 __code unixOpen(UnixFileImpl* file,Key *key, __code next(Block *block,...)); | |
23 file->fd = open(key->path,unix_mode(key->modde)); | |
24 if (fd < 0) { | |
25 goto error("can't open"); | |
26 } | |
27 goto next(readBlock(file), ...); | |
28 } | |
29 | |
30 __code uniAck(UnixFileImpl* file,Ack *ack, __code next(Block *block,...)); | |
31 if (!ack->isOk) { | |
32 close(file->fd); | |
33 goto next(...); | |
34 } | |
35 goto next(readBlock(file), ...); // file is automaticaly put into local dataGearManger/input | |
36 } | |
37 |