paul@102 | 1 | /* |
paul@102 | 2 | * A file accessor employing a file provided via the filesystem client |
paul@102 | 3 | * interface. |
paul@102 | 4 | * |
paul@102 | 5 | * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk> |
paul@102 | 6 | * |
paul@102 | 7 | * This program is free software; you can redistribute it and/or |
paul@102 | 8 | * modify it under the terms of the GNU General Public License as |
paul@102 | 9 | * published by the Free Software Foundation; either version 2 of |
paul@102 | 10 | * the License, or (at your option) any later version. |
paul@102 | 11 | * |
paul@102 | 12 | * This program is distributed in the hope that it will be useful, |
paul@102 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@102 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@102 | 15 | * GNU General Public License for more details. |
paul@102 | 16 | * |
paul@102 | 17 | * You should have received a copy of the GNU General Public License |
paul@102 | 18 | * along with this program; if not, write to the Free Software |
paul@102 | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@102 | 20 | * Boston, MA 02110-1301, USA |
paul@102 | 21 | */ |
paul@102 | 22 | |
paul@102 | 23 | #pragma once |
paul@102 | 24 | |
paul@102 | 25 | #include <fsserver/accessor.h> |
paul@102 | 26 | |
paul@102 | 27 | #include <fsclient/file.h> |
paul@102 | 28 | |
paul@102 | 29 | |
paul@102 | 30 | |
paul@102 | 31 | /* A filesystem client file accessor, providing flexpages corresponding to file |
paul@102 | 32 | regions. */ |
paul@102 | 33 | |
paul@102 | 34 | class ClientFileAccessor : public Accessor |
paul@102 | 35 | { |
paul@102 | 36 | protected: |
paul@102 | 37 | const char *_path; |
paul@102 | 38 | file_t *_file; |
paul@102 | 39 | |
paul@102 | 40 | /* Data transfer helper methods. */ |
paul@102 | 41 | |
paul@102 | 42 | virtual void fill_populated(Flexpage *flexpage); |
paul@102 | 43 | |
paul@102 | 44 | virtual void flush_populated(Flexpage *flexpage); |
paul@102 | 45 | |
paul@102 | 46 | public: |
paul@102 | 47 | explicit ClientFileAccessor(const char *path, fileid_t fileid); |
paul@102 | 48 | |
paul@102 | 49 | virtual void close(); |
paul@102 | 50 | |
paul@102 | 51 | virtual void open(); |
paul@102 | 52 | |
paul@102 | 53 | virtual offset_t get_size(); |
paul@102 | 54 | |
paul@102 | 55 | virtual void set_size(offset_t size); |
paul@102 | 56 | }; |
paul@102 | 57 | |
paul@102 | 58 | // vim: tabstop=4 expandtab shiftwidth=4 |