paul@93 | 1 | /* |
paul@93 | 2 | * An opener for a test file containing generated content. |
paul@93 | 3 | * |
paul@236 | 4 | * Copyright (C) 2021, 2022 Paul Boddie <paul@boddie.org.uk> |
paul@93 | 5 | * |
paul@93 | 6 | * This program is free software; you can redistribute it and/or |
paul@93 | 7 | * modify it under the terms of the GNU General Public License as |
paul@93 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@93 | 9 | * the License, or (at your option) any later version. |
paul@93 | 10 | * |
paul@93 | 11 | * This program is distributed in the hope that it will be useful, |
paul@93 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@93 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@93 | 14 | * GNU General Public License for more details. |
paul@93 | 15 | * |
paul@93 | 16 | * You should have received a copy of the GNU General Public License |
paul@93 | 17 | * along with this program; if not, write to the Free Software |
paul@93 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@93 | 19 | * Boston, MA 02110-1301, USA |
paul@93 | 20 | */ |
paul@93 | 21 | |
paul@9 | 22 | #pragma once |
paul@9 | 23 | |
paul@94 | 24 | #include <fsserver/opener_resource.h> |
paul@9 | 25 | |
paul@93 | 26 | |
paul@93 | 27 | |
paul@9 | 28 | /* Support for providing access to files. */ |
paul@9 | 29 | |
paul@10 | 30 | class TestFileOpener : public OpenerResource |
paul@9 | 31 | { |
paul@9 | 32 | protected: |
paul@9 | 33 | offset_t _file_size; |
paul@9 | 34 | |
paul@156 | 35 | /* Convenience methods determining different object types. */ |
paul@156 | 36 | |
paul@156 | 37 | virtual bool accessing_directory(const char *path, flags_t flags, fileid_t fileid); |
paul@156 | 38 | |
paul@156 | 39 | virtual bool accessing_file(const char *path, flags_t flags, fileid_t fileid); |
paul@156 | 40 | |
paul@144 | 41 | public: |
paul@224 | 42 | explicit TestFileOpener(ResourceRegistry *registry, offset_t file_size=0); |
paul@144 | 43 | |
paul@156 | 44 | virtual ~TestFileOpener(); |
paul@156 | 45 | |
paul@9 | 46 | /* Configurable methods. */ |
paul@9 | 47 | |
paul@146 | 48 | virtual long get_fileid(const char *path, flags_t flags, fileid_t *fileid); |
paul@9 | 49 | |
paul@202 | 50 | virtual long make_accessor(const char *path, flags_t flags, fileid_t fileid, |
paul@202 | 51 | Accessor **accessor); |
paul@202 | 52 | |
paul@202 | 53 | virtual long make_directory_accessor(const char *path, flags_t flags, |
paul@202 | 54 | fileid_t fileid, |
paul@202 | 55 | DirectoryAccessor **accessor); |
paul@232 | 56 | |
paul@232 | 57 | virtual long remove_object(const char *path, fileid_t fileid); |
paul@232 | 58 | |
paul@236 | 59 | virtual long rename_object(const char *source, fileid_t source_fileid, |
paul@236 | 60 | const char *target); |
paul@236 | 61 | |
paul@232 | 62 | virtual long unlink_object(const char *path, fileid_t fileid); |
paul@9 | 63 | }; |
paul@9 | 64 | |
paul@9 | 65 | // vim: tabstop=4 expandtab shiftwidth=4 |