ADTF  3.18.2
workspace/conan/dev_essential/1.3.3/dw/stable/package/37682420cd166e229516a41c8d6a139a0b13e1e1/include/a_util/filesystem/filesystem.h
Go to the documentation of this file.
1 
15 #ifndef _A_UTILS_UTIL_FILESYSTEM_FILESYSTEM_INCLUDED_
16 #define _A_UTILS_UTIL_FILESYSTEM_FILESYSTEM_INCLUDED_
17 
18 #include <a_util/filesystem/path.h>
19 
20 #include <string>
21 #include <vector>
22 #include <cstdint>
23 
24 namespace a_util {
25 namespace filesystem {
27 typedef enum {
28  OK,
35 
37 typedef enum {
38  ED_FILES = 0x1,
39  ED_DIRECTORIES = 0x2
41 
47 enum class DiffOptions : std::uint64_t {
48  none = 0
49 };
50 
56 
62 
71 
81 Error readTextFile(const Path& file_path, std::string& content);
82 
89 Error readTextLines(const Path& file_path, std::vector<std::string>& vec_lines);
90 
99 Error writeTextFile(const Path& file_path, const std::string& content);
100 
110 Error enumDirectory(const Path& dir_path,
111  std::vector<Path>& vec_entries,
112  std::int32_t flags = ED_FILES | ED_DIRECTORIES);
113 
119 bool exists(const Path& path);
120 
127 bool createDirectory(const Path& path);
128 
134 bool isFile(const Path& file_path);
135 
141 bool isDirectory(const Path& dir_path);
142 
149 bool remove(const Path& path);
150 
157 bool rename(const Path& path, const Path& new_path);
158 
169 std::int64_t compareFiles(const Path& p1, const Path& p2);
170 
176 std::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_
File/Directory path class.
Definition: path.h:45
Error readTextLines(const Path &file_path, std::vector< std::string > &vec_lines)
Read entire content of a text file and split it every new line, dropping the EOL characters.
Error writeTextFile(const Path &file_path, const std::string &content)
Open a file in mode 'w' and write new content to it.
bool rename(const Path &path, const Path &new_path)
Rename or move a file or directory from path to new_path.
Error enumDirectory(const Path &dir_path, std::vector< Path > &vec_entries, std::int32_t flags=ED_FILES|ED_DIRECTORIES)
List all entries in a directory.
bool remove(const Path &path)
Remove the file or directory pointed to by path.
bool createDirectory(const Path &path)
Create a new directory on the filesystem.
std::int64_t compareFiles(const Path &p1, const Path &p2)
Compare content of two files.
bool isFile(const Path &file_path)
Check whether the path points to a file on the filesystem.
Error readTextFile(const Path &file_path, std::string &content)
Read entire content of a text file into a string.
Path getTempDirectory()
Retrieve path to the temp directory of the system.
bool isDirectory(const Path &dir_path)
Check whether the path points to a directory on the filesystem.
Error setWorkingDirectory(const Path &path)
Set the working directory.
@ none
Default behavior; needs to be specified by the using function.
bool exists(const Path &path)
Check whether the file or directory exists on the filesystem.
Path getWorkingDirectory()
Retrieve path to the working directory of the current process.
Serves as the root component, with common functionality documented in core functionality.
Definition: base.h:24
Public API for Path type and functions.