paul@93 | 1 | /* |
paul@93 | 2 | * An opener for a test file containing generated content. |
paul@93 | 3 | * |
paul@93 | 4 | * Copyright (C) 2021 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 | #include "test_file_accessor.h" |
paul@9 | 23 | #include "test_file_opener.h" |
paul@9 | 24 | |
paul@9 | 25 | #include <stdlib.h> |
paul@9 | 26 | |
paul@9 | 27 | /* Support for providing access to files. */ |
paul@9 | 28 | |
paul@79 | 29 | TestFileOpener::TestFileOpener(Pages *pages, offset_t file_size) |
paul@79 | 30 | : OpenerResource(pages), _file_size(file_size) |
paul@9 | 31 | { |
paul@9 | 32 | } |
paul@9 | 33 | |
paul@9 | 34 | /* Return a file identifier for the given 'path'. */ |
paul@9 | 35 | |
paul@9 | 36 | fileid_t TestFileOpener::get_fileid(const char *path) |
paul@9 | 37 | { |
paul@9 | 38 | /* NOTE: Just convert the path to a number. */ |
paul@9 | 39 | |
paul@9 | 40 | return atol(path); |
paul@9 | 41 | } |
paul@9 | 42 | |
paul@9 | 43 | /* Return a new accessor for 'fileid'. */ |
paul@9 | 44 | |
paul@9 | 45 | Accessor *TestFileOpener::make_accessor(fileid_t fileid) |
paul@9 | 46 | { |
paul@9 | 47 | return new TestFileAccessor(fileid, _file_size); |
paul@9 | 48 | } |
paul@9 | 49 | |
paul@9 | 50 | // vim: tabstop=4 expandtab shiftwidth=4 |