Landfall

Annotated pkg/landfall-examples/msc_block_server/msc_region_opener.h

273:8f6ff113d000
8 months ago Paul Boddie Removed debugging output. cpm-library-improvements
paul@272 1
/*
paul@272 2
 * An opener for regions of a memory card.
paul@272 3
 *
paul@272 4
 * Copyright (C) 2021, 2022, 2024 Paul Boddie <paul@boddie.org.uk>
paul@272 5
 *
paul@272 6
 * This program is free software; you can redistribute it and/or
paul@272 7
 * modify it under the terms of the GNU General Public License as
paul@272 8
 * published by the Free Software Foundation; either version 2 of
paul@272 9
 * the License, or (at your option) any later version.
paul@272 10
 *
paul@272 11
 * This program is distributed in the hope that it will be useful,
paul@272 12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
paul@272 13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
paul@272 14
 * GNU General Public License for more details.
paul@272 15
 *
paul@272 16
 * You should have received a copy of the GNU General Public License
paul@272 17
 * along with this program; if not, write to the Free Software
paul@272 18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
paul@272 19
 * Boston, MA  02110-1301, USA
paul@272 20
 */
paul@272 21
paul@272 22
#pragma once
paul@272 23
paul@272 24
#include <mutex>
paul@272 25
paul@272 26
#include <fsserver/opener_resource.h>
paul@272 27
paul@272 28
#include "msc_region_operations.h"
paul@272 29
paul@272 30
paul@272 31
paul@272 32
/* Support for providing access to memory card regions. */
paul@272 33
paul@272 34
class MscRegionOpener : public OpenerResource
paul@272 35
{
paul@272 36
protected:
paul@272 37
    MscRegionOperations *_ops;
paul@272 38
    std::mutex _lock;
paul@272 39
paul@272 40
public:
paul@272 41
    explicit MscRegionOpener(ResourceRegistry *registry, MscRegionOperations *ops)
paul@272 42
    : OpenerResource(registry), _ops(ops)
paul@272 43
    {
paul@272 44
    }
paul@272 45
paul@272 46
    virtual ~MscRegionOpener();
paul@272 47
paul@272 48
    /* Convenience methods determining different object types. */
paul@272 49
paul@272 50
    virtual bool accessing_directory(flags_t flags, fileid_t fileid);
paul@272 51
paul@272 52
    virtual bool accessing_file(flags_t flags, fileid_t fileid);
paul@272 53
paul@272 54
    virtual bool directory_is_empty(fileid_t fileid);
paul@272 55
paul@272 56
    /* File opening methods. */
paul@272 57
paul@272 58
    virtual long get_fileid(const char *path, flags_t flags, fileid_t *fileid);
paul@272 59
paul@272 60
    virtual long make_accessor(flags_t flags, fileid_t fileid,
paul@272 61
                               Accessor **accessor);
paul@272 62
paul@272 63
    virtual long make_directory_accessor(flags_t flags, fileid_t fileid,
paul@272 64
                                         DirectoryAccessor **accessor);
paul@272 65
paul@272 66
    /* Filesystem object access and manipulation methods. */
paul@272 67
paul@272 68
    virtual long make_directory_object(const char *path, sys_mode_t mode);
paul@272 69
paul@272 70
    virtual long remove_object(fileid_t fileid);
paul@272 71
paul@272 72
    virtual long rename_object(const char *source, const char *target);
paul@272 73
paul@272 74
    virtual long stat_object(const char *path, void *base, offset_t size);
paul@272 75
paul@272 76
    virtual long unlink_object(fileid_t parent_fileid, fileid_t fileid);
paul@272 77
};
paul@272 78
paul@272 79
// vim: tabstop=4 expandtab shiftwidth=4