open_dir.hpp 1.06 KiB
Newer Older
/*
  Copyright 2018-2019, Barcelona Supercomputing Center (BSC), Spain
  Copyright 2015-2019, Johannes Gutenberg Universitaet Mainz, Germany

  This software was partially supported by the
  EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu).

  This software was partially supported by the
  ADA-FS project under the SPPEXA project funded by the DFG.

  SPDX-License-Identifier: MIT
*/

Tommaso Tocci's avatar
Tommaso Tocci committed

#ifndef IFS_OPEN_DIR_HPP
#define IFS_OPEN_DIR_HPP

#include <string>
#include <vector>

#include <dirent.h>

#include <client/open_file_map.hpp>
Tommaso Tocci's avatar
Tommaso Tocci committed
class DirEntry {
Tommaso Tocci's avatar
Tommaso Tocci committed
    private:
Tommaso Tocci's avatar
Tommaso Tocci committed
        std::string name_;
        FileType type_;
    public:
        DirEntry(const std::string& name, const FileType type);
        const std::string& name();
        FileType type();
};
Tommaso Tocci's avatar
Tommaso Tocci committed

Tommaso Tocci's avatar
Tommaso Tocci committed
class OpenDir: public OpenFile {
    private:
Tommaso Tocci's avatar
Tommaso Tocci committed
        std::vector<DirEntry> entries;


    public:
        OpenDir(const std::string& path);
Tommaso Tocci's avatar
Tommaso Tocci committed
        void add(const std::string& name, const FileType& type);
Tommaso Tocci's avatar
Tommaso Tocci committed
        const DirEntry& getdent(unsigned int pos);
Tommaso Tocci's avatar
Tommaso Tocci committed
        size_t size();
Tommaso Tocci's avatar
Tommaso Tocci committed
};


#endif //IFS_OPEN_DIR_HPP