1 #include "accessor.h" 2 3 #include <string.h> 4 5 6 7 Accessor::Accessor(fileid_t fileid, offset_t size) 8 : _size(size), fileid(fileid) 9 { 10 } 11 12 /* Return the size of the file. */ 13 14 offset_t Accessor::get_size() 15 { 16 return _size; 17 } 18 19 /* Update the size of the file. */ 20 21 void Accessor::set_size(offset_t size) 22 { 23 _size = size; 24 } 25 26 /* Perform any closing operation on the file. */ 27 28 void Accessor::close() 29 { 30 } 31 32 /* Perform any opening operation on the file. */ 33 34 void Accessor::open() 35 { 36 } 37 38 /* Data transfer methods. */ 39 40 void Accessor::fill(Flexpage *flexpage) 41 { 42 /* Filling completely beyond the end of file should produce an empty 43 flexpage. This could potentially be a shared read-only flexpage that 44 would be replaced by an independent writable flexpage if ever written. */ 45 46 if (flexpage->base_offset < _size) 47 fill_populated(flexpage); 48 else 49 memset((void *) flexpage->base_addr, 0, flexpage->size); 50 } 51 52 void Accessor::flush(Flexpage *flexpage) 53 { 54 /* Flushing completely beyond the end of file should discard the 55 flexpage. */ 56 57 if (flexpage->base_offset < _size) 58 flush_populated(flexpage); 59 } 60 61 /* Data transfer helper methods. */ 62 63 void Accessor::fill_populated(Flexpage *flexpage) 64 { 65 (void) flexpage; 66 } 67 68 void Accessor::flush_populated(Flexpage *flexpage) 69 { 70 (void) flexpage; 71 } 72 73 // vim: tabstop=4 expandtab shiftwidth=4