1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/generic/accessor.cc Fri Apr 02 01:27:50 2021 +0200
1.3 @@ -0,0 +1,73 @@
1.4 +#include "accessor.h"
1.5 +
1.6 +#include <string.h>
1.7 +
1.8 +
1.9 +
1.10 +Accessor::Accessor(fileid_t fileid, offset_t size)
1.11 +: _size(size), fileid(fileid)
1.12 +{
1.13 +}
1.14 +
1.15 +/* Return the size of the file. */
1.16 +
1.17 +offset_t Accessor::get_size()
1.18 +{
1.19 + return _size;
1.20 +}
1.21 +
1.22 +/* Update the size of the file. */
1.23 +
1.24 +void Accessor::set_size(offset_t size)
1.25 +{
1.26 + _size = size;
1.27 +}
1.28 +
1.29 +/* Perform any closing operation on the file. */
1.30 +
1.31 +void Accessor::close()
1.32 +{
1.33 +}
1.34 +
1.35 +/* Perform any opening operation on the file. */
1.36 +
1.37 +void Accessor::open()
1.38 +{
1.39 +}
1.40 +
1.41 +/* Data transfer methods. */
1.42 +
1.43 +void Accessor::fill(Flexpage *flexpage)
1.44 +{
1.45 + /* Filling completely beyond the end of file should produce an empty
1.46 + flexpage. This could potentially be a shared read-only flexpage that
1.47 + would be replaced by an independent writable flexpage if ever written. */
1.48 +
1.49 + if (flexpage->base_offset < _size)
1.50 + fill_populated(flexpage);
1.51 + else
1.52 + memset((void *) flexpage->base_addr, 0, flexpage->size);
1.53 +}
1.54 +
1.55 +void Accessor::flush(Flexpage *flexpage)
1.56 +{
1.57 + /* Flushing completely beyond the end of file should discard the
1.58 + flexpage. */
1.59 +
1.60 + if (flexpage->base_offset < _size)
1.61 + flush_populated(flexpage);
1.62 +}
1.63 +
1.64 +/* Data transfer helper methods. */
1.65 +
1.66 +void Accessor::fill_populated(Flexpage *flexpage)
1.67 +{
1.68 + (void) flexpage;
1.69 +}
1.70 +
1.71 +void Accessor::flush_populated(Flexpage *flexpage)
1.72 +{
1.73 + (void) flexpage;
1.74 +}
1.75 +
1.76 +// vim: tabstop=4 expandtab shiftwidth=4