Dev Essential
Loading...
Searching...
No Matches
filesystem.h
Go to the documentation of this file.
1
14
15#ifndef _A_UTILS_UTIL_FILESYSTEM_FILESYSTEM_INCLUDED_
16#define _A_UTILS_UTIL_FILESYSTEM_FILESYSTEM_INCLUDED_
17
19
20#include <string>
21#include <vector>
22#include <cstdint>
23
24namespace a_util {
25namespace filesystem {
35
37typedef enum {
38 ED_FILES = 0x1,
41
47enum class DiffOptions : std::uint64_t {
48 none = 0
49};
50
56
62
71
81Error readTextFile(const Path& file_path, std::string& content);
82
89Error readTextLines(const Path& file_path, std::vector<std::string>& vec_lines);
90
99Error writeTextFile(const Path& file_path, const std::string& content);
100
110Error enumDirectory(const Path& dir_path,
111 std::vector<Path>& vec_entries,
112 std::int32_t flags = ED_FILES | ED_DIRECTORIES);
113
119bool exists(const Path& path);
120
127bool createDirectory(const Path& path);
128
134bool isFile(const Path& file_path);
135
141bool isDirectory(const Path& dir_path);
142
149bool remove(const Path& path);
150
157bool rename(const Path& path, const Path& new_path);
158
169std::int64_t compareFiles(const Path& p1, const Path& p2);
170
176std::int64_t compareFiles(const Path& p1, const Path& p2, DiffOptions options);
177
178} // namespace filesystem
179} // namespace a_util
180
181#endif // _A_UTILS_UTIL_FILESYSTEM_FILESYSTEM_INCLUDED_
Definition path.h:46
Serves as component for path and filesystem functionality.
Definition filesystem.h:20
Error readTextLines(const Path &file_path, std::vector< std::string > &vec_lines)
Error writeTextFile(const Path &file_path, const std::string &content)
bool rename(const Path &path, const Path &new_path)
EnumDirFlags
Enumeration for possible listings in a directory, usable in function enumDirectory()
Definition filesystem.h:37
@ ED_DIRECTORIES
List directories in the directory.
Definition filesystem.h:39
@ ED_FILES
List files in the directory.
Definition filesystem.h:38
Error enumDirectory(const Path &dir_path, std::vector< Path > &vec_entries, std::int32_t flags=ED_FILES|ED_DIRECTORIES)
Path getWorkingDirectory()
bool remove(const Path &path)
bool createDirectory(const Path &path)
std::int64_t compareFiles(const Path &p1, const Path &p2)
bool isFile(const Path &file_path)
Error readTextFile(const Path &file_path, std::string &content)
DiffOptions
Definition filesystem.h:47
@ none
Default behavior; needs to be specified by the using function.
Definition filesystem.h:48
bool isDirectory(const Path &dir_path)
Error setWorkingDirectory(const Path &path)
bool exists(const Path &path)
Error
Enumerates possible error values for filesystem interaction.
Definition filesystem.h:27
@ ACCESS_DENIED
Access to file or folder in the filesystem denied.
Definition filesystem.h:33
@ OPEN_FAILED
Opening a file or folder from the filesystem failed.
Definition filesystem.h:29
@ OK
No error, basically meaning success.
Definition filesystem.h:28
@ INVALID_PATH
Accessed path on the filesystem is invalid.
Definition filesystem.h:32
@ GENERAL_FAILURE
General errors.
Definition filesystem.h:30
@ IO_ERROR
Input/output error during filesystem access.
Definition filesystem.h:31
Serves as the root component, with common functionality documented in core functionality.
Definition base.h:24