STORMM Source Documentation
Loading...
Searching...
No Matches
file_listing.h
1// -*-c++-*-
2#ifndef STORMM_FILE_LISTING_H
3#define STORMM_FILE_LISTING_H
4
5#include <vector>
6#include <string>
7#include "copyright.h"
8
9namespace stormm {
10namespace diskutil {
11
14enum class SearchStyle {
15 RECURSIVE, NON_RECURSIVE
16};
17
20enum class DrivePathType {
21 FILE, DIRECTORY, REGEXP
22};
23
25enum class OperatingSystem {
26 LINUX, UNIX, WINDOWS, MAC_OS
27};
28
31#if defined(__linux__)
32constexpr OperatingSystem detected_os = OperatingSystem::LINUX;
33#elif defined(unix) || defined(__unix) || defined(__unix__)
34constexpr OperatingSystem detected_os = OperatingSystem::UNIX;
35#elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
36constexpr OperatingSystem detected_os = OperatingSystem::WINDOWS;
37#elif defined(__APPLE__) || defined(__MACH__)
38constexpr OperatingSystem detected_os = OperatingSystem::MAC_OS;
39#endif
41
43char osSeparator();
44
48DrivePathType getDrivePathType(const std::string &path);
49
55std::vector<std::string> listDirectory(const std::string &path,
56 SearchStyle r_option = SearchStyle::NON_RECURSIVE,
57 DrivePathType entity_kind = DrivePathType::FILE);
58
63bool pathIsAbsolute(const std::string &path);
64
68std::string makePathAbsolute(const std::string &path);
69
73std::string getNormPath(const std::string &path);
74
78std::string getBaseName(const std::string &path);
79
86std::string substituteNameExtension(const std::string &path, const std::string &new_ext);
87
91std::vector<std::string> separatePath(const std::string &path);
92
98void splitPath(const std::string &path, std::string *before, std::string *after);
99
112std::vector<std::string> listFilesInPath(const std::string &regexp_path, SearchStyle r_option);
113
120std::string findStormmPath(const std::string &path, const std::string &extension);
121
127std::string commonPathVariableName(int index);
128
141std::vector<std::string> extractCommonPaths(std::vector<std::string> *input_paths,
142 int n_shortcut = 2, int n_instance = 2);
143
148std::string listCommonPaths(const std::vector<std::string> &shortcuts, int indentation = 2);
149
150} // namespace parse
151} // namespace stormm
152
153#endif