1 /* 2 * An opener for regions of a memory card. 3 * 4 * Copyright (C) 2021, 2022, 2024 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 #pragma once 23 24 #include <mutex> 25 26 #include <fsserver/opener_resource.h> 27 28 #include "msc_region_operations.h" 29 30 31 32 /* Support for providing access to memory card regions. */ 33 34 class MscRegionOpener : public OpenerResource 35 { 36 protected: 37 MscRegionOperations *_ops; 38 std::mutex _lock; 39 40 public: 41 explicit MscRegionOpener(ResourceRegistry *registry, MscRegionOperations *ops) 42 : OpenerResource(registry), _ops(ops) 43 { 44 } 45 46 virtual ~MscRegionOpener(); 47 48 /* Convenience methods determining different object types. */ 49 50 virtual bool accessing_directory(flags_t flags, fileid_t fileid); 51 52 virtual bool accessing_file(flags_t flags, fileid_t fileid); 53 54 virtual bool directory_is_empty(fileid_t fileid); 55 56 /* File opening methods. */ 57 58 virtual long get_fileid(const char *path, flags_t flags, fileid_t *fileid); 59 60 virtual long make_accessor(flags_t flags, fileid_t fileid, 61 Accessor **accessor); 62 63 virtual long make_directory_accessor(flags_t flags, fileid_t fileid, 64 DirectoryAccessor **accessor); 65 66 /* Filesystem object access and manipulation methods. */ 67 68 virtual long make_directory_object(const char *path, sys_mode_t mode); 69 70 virtual long remove_object(fileid_t fileid); 71 72 virtual long rename_object(const char *source, const char *target); 73 74 virtual long stat_object(const char *path, void *base, offset_t size); 75 76 virtual long unlink_object(fileid_t parent_fileid, fileid_t fileid); 77 }; 78 79 // vim: tabstop=4 expandtab shiftwidth=4