1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/libfsserver/include/fsserver/client_file_accessor.h Sun Apr 18 22:32:54 2021 +0200
1.3 @@ -0,0 +1,58 @@
1.4 +/*
1.5 + * A file accessor employing a file provided via the filesystem client
1.6 + * interface.
1.7 + *
1.8 + * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk>
1.9 + *
1.10 + * This program is free software; you can redistribute it and/or
1.11 + * modify it under the terms of the GNU General Public License as
1.12 + * published by the Free Software Foundation; either version 2 of
1.13 + * the License, or (at your option) any later version.
1.14 + *
1.15 + * This program is distributed in the hope that it will be useful,
1.16 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.17 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.18 + * GNU General Public License for more details.
1.19 + *
1.20 + * You should have received a copy of the GNU General Public License
1.21 + * along with this program; if not, write to the Free Software
1.22 + * Foundation, Inc., 51 Franklin Street, Fifth Floor,
1.23 + * Boston, MA 02110-1301, USA
1.24 + */
1.25 +
1.26 +#pragma once
1.27 +
1.28 +#include <fsserver/accessor.h>
1.29 +
1.30 +#include <fsclient/file.h>
1.31 +
1.32 +
1.33 +
1.34 +/* A filesystem client file accessor, providing flexpages corresponding to file
1.35 + regions. */
1.36 +
1.37 +class ClientFileAccessor : public Accessor
1.38 +{
1.39 +protected:
1.40 + const char *_path;
1.41 + file_t *_file;
1.42 +
1.43 + /* Data transfer helper methods. */
1.44 +
1.45 + virtual void fill_populated(Flexpage *flexpage);
1.46 +
1.47 + virtual void flush_populated(Flexpage *flexpage);
1.48 +
1.49 +public:
1.50 + explicit ClientFileAccessor(const char *path, fileid_t fileid);
1.51 +
1.52 + virtual void close();
1.53 +
1.54 + virtual void open();
1.55 +
1.56 + virtual offset_t get_size();
1.57 +
1.58 + virtual void set_size(offset_t size);
1.59 +};
1.60 +
1.61 +// vim: tabstop=4 expandtab shiftwidth=4