paul@93 | 1 | /* |
paul@224 | 2 | * A registry of filesystem object resources. |
paul@93 | 3 | * |
paul@240 | 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@202 | 24 | #include <fsserver/directory_provider.h> |
paul@144 | 25 | #include <fsserver/file_opening.h> |
paul@200 | 26 | #include <fsserver/file_provider.h> |
paul@94 | 27 | #include <fsserver/pager.h> |
paul@144 | 28 | #include <fsserver/pages.h> |
paul@224 | 29 | #include <fsserver/provider_registry.h> |
paul@9 | 30 | |
paul@9 | 31 | |
paul@9 | 32 | |
paul@224 | 33 | /* A registry of filesystem object resources. */ |
paul@9 | 34 | |
paul@224 | 35 | class ResourceRegistry : public ProviderRegistry |
paul@9 | 36 | { |
paul@9 | 37 | protected: |
paul@79 | 38 | Pages *_pages; |
paul@9 | 39 | |
paul@144 | 40 | map_flags_t get_flags(flags_t flags); |
paul@144 | 41 | |
paul@220 | 42 | /* Provider initialisation methods. */ |
paul@220 | 43 | |
paul@240 | 44 | long make_directory_provider(FileOpening *opening, flags_t flags, |
paul@240 | 45 | fileid_t fileid, Provider **provider); |
paul@202 | 46 | |
paul@240 | 47 | long make_file_provider(FileOpening *opening, flags_t flags, |
paul@240 | 48 | fileid_t fileid, Provider **provider); |
paul@220 | 49 | |
paul@240 | 50 | long make_provider(FileOpening *opening, flags_t flags, |
paul@240 | 51 | fileid_t fileid, Provider **provider); |
paul@193 | 52 | |
paul@236 | 53 | /* Provider manipulation methods. */ |
paul@236 | 54 | |
paul@240 | 55 | long _remove_provider(FileOpening *opening, const char *path, fileid_t fileid); |
paul@236 | 56 | |
paul@79 | 57 | public: |
paul@224 | 58 | explicit ResourceRegistry(Pages *pages); |
paul@79 | 59 | |
paul@232 | 60 | /* Provider discovery methods. |
paul@232 | 61 | NOTE: To be protected, potentially. */ |
paul@208 | 62 | |
paul@220 | 63 | long find_provider(fileid_t fileid, Provider **provider); |
paul@208 | 64 | |
paul@202 | 65 | /* Resource initialisation methods. */ |
paul@144 | 66 | |
paul@218 | 67 | long get_resource(FileOpening *opening, const char *path, flags_t flags, |
paul@218 | 68 | offset_t *size, object_flags_t *object_flags, |
paul@218 | 69 | Resource **resource); |
paul@232 | 70 | |
paul@232 | 71 | /* Provider manipulation methods. */ |
paul@232 | 72 | |
paul@232 | 73 | long remove_provider(FileOpening *opening, const char *path); |
paul@236 | 74 | |
paul@236 | 75 | long rename_provider(FileOpening *opening, const char *source, const char *target); |
paul@9 | 76 | }; |
paul@9 | 77 | |
paul@9 | 78 | // vim: tabstop=4 expandtab shiftwidth=4 |