MARLEY (Model of Argon Reaction Low Energy Yields) v2.0.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
Loading...
Searching...
No Matches
FileManager.hh
1
4//
5// This file is part of MARLEY (Model of Argon Reaction Low Energy Yields)
6//
7// MARLEY is free software: you can redistribute it and/or modify it under the
8// terms of version 3 of the GNU General Public License as published by the
9// Free Software Foundation.
10//
11// For the full text of the license please see COPYING or
12// visit http://opensource.org/licenses/GPL-3.0
13//
14// Please respect the MCnet academic usage guidelines. See GUIDELINES
15// or visit https://www.montecarlonet.org/GUIDELINES for details.
16
17#pragma once
18#include <functional>
19#include <string>
20#include <vector>
21
22namespace marley {
23
26
27 public:
28
30 FileManager(const FileManager&) = delete;
31
34
37
40
43 static const FileManager& Instance();
44
51 static std::vector<std::string> search_path_to_dir_vector(
52 const std::string& search_path = FileManager::default_search_path_);
53
66 std::string find_file(const std::string& base_name,
67 const std::vector<std::string>& search_dirs) const;
68
78 std::string find_file(const std::string& base_name,
79 const std::string& search_path
81
90 std::vector<std::string> list_all_files(
91 const std::vector<std::string>& search_dirs) const;
92
101 std::vector<std::string> list_all_files(
102 const std::string& search_path
104
106 inline std::string marley_dir() const { return marley_dir_; }
107
108 protected:
109
111 FileManager();
112
124 static bool dir_iterate(const std::string& dir_name,
125 const std::function<bool(const std::string&, const std::string&)>& func);
126
128 static std::string default_search_path_;
129
132 std::string marley_dir_;
133 };
134
135}
std::string marley_dir() const
Returns the path to the root MARLEY folder.
FileManager & operator=(const FileManager &)=delete
Deleted copy assignment operator.
std::string marley_dir_
Stores the value of the MARLEY environment variable (which points to the root folder of the source co...
FileManager()
Create the singleton FileManager object.
std::vector< std::string > list_all_files(const std::vector< std::string > &search_dirs) const
Get a vector of full paths for all regular files in the requested directories.
FileManager(FileManager &&)=delete
Deleted move constructor.
static std::string default_search_path_
By default, use this search path when looking for files.
FileManager(const FileManager &)=delete
Deleted copy constructor.
FileManager & operator=(FileManager &&)=delete
Deleted move assignment operator.
static std::vector< std::string > search_path_to_dir_vector(const std::string &search_path=FileManager::default_search_path_)
Converts a ':'-delimited search path (given as a single string) into a vector of directory names.
static bool dir_iterate(const std::string &dir_name, const std::function< bool(const std::string &, const std::string &)> &func)
Helper function that executes a std::function on the name of each regular file found while scanning t...
static const FileManager & Instance()
Get a const reference to the singleton instance of the FileManager.
std::string find_file(const std::string &base_name, const std::vector< std::string > &search_dirs) const
Searches for a file in the given directories.