1 #ifndef FILE_SYSTEM_HPP
2 #define FILE_SYSTEM_HPP
21 #include "os_fixes.hpp"
26 bool is_present(
const std::string& thing);
27 bool is_folder(
const std::string& thing);
28 bool is_file(
const std::string& thing);
33 bool file_exists(
const std::string& filespec);
34 bool file_readable(
const std::string& filespec);
35 bool file_writable(
const std::string& filespec);
36 size_t file_size(
const std::string& filespec);
37 bool file_delete(
const std::string& filespec);
38 bool file_rename(
const std::string& old_filespec,
const std::string& new_filespec);
39 bool file_move(
const std::string& old_filespec,
const std::string& new_filespec);
40 bool file_copy(
const std::string& old_filespec,
const std::string& new_filespec);
57 extern const int read__mode;
58 extern const int write_mode;
59 extern const int execute_mode;
61 extern const int none_mode;
62 extern const int read_write_mode;
63 extern const int all_mode;
65 extern const int owner_mask;
66 extern const int group_mask;
67 extern const int other_mask;
69 extern const int non_owner_mask;
70 extern const int all_mask;
72 extern const int read_mode_all;
73 extern const int read_write_mode_owner_read_mode_all;
74 extern const int read_mode_owner_only;
75 extern const int read_write_mode_owner_only;
77 bool file_set_mode(
const std::string& filespec,
int mode);
80 time_t file_created(
const std::string& filespec);
81 time_t file_modified(
const std::string& filespec);
82 time_t file_accessed(
const std::string& filespec);
84 std::string create_filespec(
const std::string& folder,
const std::string& filename);
85 std::string create_filespec(
const std::string& folder,
const std::string& basename,
const std::string& extension);
86 std::string create_filename(
const std::string& basename,
const std::string& extension);
91 bool folder_create(
const std::string& folder);
92 bool folder_exists(
const std::string& folder);
93 bool folder_readable(
const std::string& folder);
94 bool folder_writable(
const std::string& folder);
95 bool folder_delete(
const std::string& folder,
bool recurse =
false);
96 bool folder_rename(
const std::string& old_directory,
const std::string& new_directory);
97 bool folder_empty(
const std::string& folder);
99 bool folder_set_current(
const std::string& folder);
100 std::string folder_current(
void);
101 std::string folder_current_full(
void);
102 std::string folder_home(
void);
103 std::string folder_down(
const std::string& folder,
const std::string& subfolder);
104 std::string folder_up(
const std::string& folder,
unsigned levels = 1);
106 std::vector<std::string> folder_subdirectories(
const std::string& folder);
107 std::vector<std::string> folder_files(
const std::string& folder);
108 std::vector<std::string> folder_all(
const std::string& folder);
109 std::vector<std::string> folder_wildcard(
const std::string& folder,
const std::string& wildcard,
bool subdirs =
true,
115 bool is_full_path(
const std::string& path);
116 bool is_relative_path(
const std::string& path);
119 std::string folder_to_path(
const std::string& root,
const std::string& folder);
120 std::string filespec_to_path(
const std::string& root,
const std::string& filespec);
123 std::string folder_to_path(
const std::string& folder);
124 std::string filespec_to_path(
const std::string& filespec);
127 std::string folder_to_relative_path(
const std::string& root,
const std::string& folder);
128 std::string filespec_to_relative_path(
const std::string& root,
const std::string& filespec);
131 std::string folder_to_relative_path(
const std::string& folder);
132 std::string filespec_to_relative_path(
const std::string& filespec);
135 std::string folder_append_separator(
const std::string& folder);
140 std::string basename_part(
const std::string& filespec);
141 std::string filename_part(
const std::string& filespec);
142 std::string extension_part(
const std::string& filespec);
143 std::string folder_part(
const std::string& filespec);
146 std::vector<std::string> folder_elements(
const std::string& folder);
147 std::vector<std::string> filespec_elements(
const std::string& filespec);
153 #define PATH_SPLITTER ";"
155 #define PATH_SPLITTER ":"
161 std::string path_lookup(
const std::string& command);
167 std::string lookup(
const std::string& file,
const std::string& path,
const std::string& splitter = PATH_SPLITTER);
171 std::string install_path(
const std::string& argv0);