Line data Source code
1 : /* 2 : Copyright 2018-2024, Barcelona Supercomputing Center (BSC), Spain 3 : Copyright 2015-2024, Johannes Gutenberg Universitaet Mainz, Germany 4 : 5 : This software was partially supported by the 6 : EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu). 7 : 8 : This software was partially supported by the 9 : ADA-FS project under the SPPEXA project funded by the DFG. 10 : 11 : This file is part of GekkoFS' POSIX interface. 12 : 13 : GekkoFS' POSIX interface is free software: you can redistribute it and/or 14 : modify it under the terms of the GNU Lesser General Public License as 15 : published by the Free Software Foundation, either version 3 of the License, 16 : or (at your option) any later version. 17 : 18 : GekkoFS' POSIX interface is distributed in the hope that it will be useful, 19 : but WITHOUT ANY WARRANTY; without even the implied warranty of 20 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 : GNU Lesser General Public License for more details. 22 : 23 : You should have received a copy of the GNU Lesser General Public License 24 : along with GekkoFS' POSIX interface. If not, see 25 : <https://www.gnu.org/licenses/>. 26 : 27 : SPDX-License-Identifier: LGPL-3.0-or-later 28 : */ 29 : 30 : #include <client/open_dir.hpp> 31 : #include <stdexcept> 32 : #include <cstring> 33 : 34 : namespace gkfs::filemap { 35 : 36 1029 : DirEntry::DirEntry(const std::string& name, const FileType type) 37 1029 : : name_(name), type_(type) {} 38 : 39 : const std::string& 40 4100 : DirEntry::name() { 41 4100 : return name_; 42 : } 43 : 44 : FileType 45 1025 : DirEntry::type() { 46 1025 : return type_; 47 : } 48 : 49 : 50 25 : OpenDir::OpenDir(const std::string& path) 51 25 : : OpenFile(path, 0, FileType::directory) {} 52 : 53 : 54 : void 55 1029 : OpenDir::add(const std::string& name, const FileType& type) { 56 1029 : entries.push_back(DirEntry(name, type)); 57 1029 : } 58 : 59 : const DirEntry& 60 1025 : OpenDir::getdent(unsigned int pos) { 61 1025 : return entries.at(pos); 62 : } 63 : 64 : size_t 65 1071 : OpenDir::size() { 66 1071 : return entries.size(); 67 : } 68 : 69 : } // namespace gkfs::filemap