1 /* 2 * Generic accessor functionality. 3 * 4 * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA 20 */ 21 22 #include "accessor.h" 23 24 #include <string.h> 25 26 27 28 Accessor::Accessor(fileid_t fileid) 29 : fileid(fileid) 30 { 31 } 32 33 Accessor::~Accessor() 34 { 35 close(); 36 } 37 38 /* Perform any closing operation on the file. */ 39 40 void Accessor::close() 41 { 42 } 43 44 /* Data transfer methods. */ 45 46 void Accessor::fill(Flexpage *flexpage) 47 { 48 /* Filling completely beyond the end of file should produce an empty 49 flexpage. This could potentially be a shared read-only flexpage that 50 would be replaced by an independent writable flexpage if ever written. */ 51 52 if (flexpage->base_offset < get_size()) 53 fill_populated(flexpage); 54 else 55 memset((void *) flexpage->base_addr, 0, flexpage->size); 56 } 57 58 void Accessor::flush(Flexpage *flexpage) 59 { 60 /* Flushing completely beyond the end of file should discard the 61 flexpage. */ 62 63 if (flexpage->base_offset < get_size()) 64 flush_populated(flexpage); 65 } 66 67 /* Data transfer helper methods. */ 68 69 void Accessor::fill_populated(Flexpage *flexpage) 70 { 71 (void) flexpage; 72 } 73 74 void Accessor::flush_populated(Flexpage *flexpage) 75 { 76 (void) flexpage; 77 } 78 79 /* Lifecycle methods. */ 80 81 /* Remove a filesystem object. */ 82 83 void Accessor::remove() 84 { 85 } 86 87 // vim: tabstop=4 expandtab shiftwidth=4