diff options
Diffstat (limited to 'src/server/buffer.cpp')
-rw-r--r-- | src/server/buffer.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/server/buffer.cpp b/src/server/buffer.cpp index 7b4c92d..62c7ea9 100644 --- a/src/server/buffer.cpp +++ b/src/server/buffer.cpp @@ -14,9 +14,9 @@ struct Buffer { void read_file(const char *pathname) { free_storage(); - int file = open(pathname, O_RDONLY); + File file(pathname, O_RDONLY); storage = new Page(); - int bytes_read = read(file, storage->elements, PAGE_SIZE); + int bytes_read = file.recv(storage->elements, PAGE_SIZE); Page *iter = storage; while (bytes_read > 0) { iter->gap_start = bytes_read; @@ -24,22 +24,20 @@ struct Buffer { iter->next = new Page(); iter->next->prev = iter; iter = iter->next; - bytes_read = read(file, iter->elements, PAGE_SIZE); + bytes_read = file.recv(iter->elements, PAGE_SIZE); } if (iter->element_count == 0) { delete iter; } - close(file); } void write_file(const char *pathname) { - int file = open(pathname, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + File file(pathname, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); Page *iter = storage; while (iter) { - write(file, iter->elements, iter->gap_start); - write(file, iter->elements + iter->gap_end, PAGE_SIZE - iter->gap_end); + file.send(iter->elements, iter->gap_start); + file.send(iter->elements + iter->gap_end, PAGE_SIZE - iter->gap_end); iter = iter->next; } - close(file); } }; |