ADTF
|
Serves as component for path and filesystem functionality. More...
Classes | |
class | PathException |
Exception class used by Path methods. More... | |
class | Path |
File/Directory path class. More... | |
Enumerations | |
enum | Error { OK , OPEN_FAILED , GENERAL_FAILURE , IO_ERROR , INVALID_PATH , ACCESS_DENIED } |
Enumerates possible error values for filesystem interaction. More... | |
enum | EnumDirFlags { ED_FILES = 0x1 , ED_DIRECTORIES = 0x2 } |
Enumeration for possible listings in a directory, usable in function enumDirectory() More... | |
enum class | DiffOptions : std::uint64_t { none = 0 } |
Available options for operations comparing files or directories. More... | |
Functions | |
Path | getTempDirectory () |
Retrieve path to the temp directory of the system. More... | |
Path | getWorkingDirectory () |
Retrieve path to the working directory of the current process. More... | |
Error | setWorkingDirectory (const Path &path) |
Set the working directory. More... | |
Error | readTextFile (const Path &file_path, std::string &content) |
Read entire content of a text file into a string. More... | |
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. More... | |
Error | writeTextFile (const Path &file_path, const std::string &content) |
Open a file in mode 'w' and write new content to it. More... | |
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. More... | |
bool | exists (const Path &path) |
Check whether the file or directory exists on the filesystem. More... | |
bool | createDirectory (const Path &path) |
Create a new directory on the filesystem. More... | |
bool | isFile (const Path &file_path) |
Check whether the path points to a file on the filesystem. More... | |
bool | isDirectory (const Path &dir_path) |
Check whether the path points to a directory on the filesystem. More... | |
bool | remove (const Path &path) |
Remove the file or directory pointed to by path . More... | |
bool | rename (const Path &path, const Path &new_path) |
Rename or move a file or directory from path to new_path . More... | |
std::int64_t | compareFiles (const Path &p1, const Path &p2) |
Compare content of two files. More... | |
std::int64_t | compareFiles (const Path &p1, const Path &p2, DiffOptions options) |
Compare content of two files. More... | |
bool | operator== (const Path &lhs, const Path &rhs) |
Check two paths for equality. More... | |
bool | operator!= (const Path &lhs, const Path &rhs) |
Check two paths for inequality. More... | |
std::ostream & | operator<< (std::ostream &os, const Path &p) |
Performs stream output on the path p. More... | |
Path | operator+ (const Path &a, const Path &b) |
Appends two paths, forming a new path. More... | |
Serves as component for path and filesystem functionality.
|
strong |
Available options for operations comparing files or directories.
Enumerator | |
---|---|
none | Default behavior; needs to be specified by the using function. |
Definition at line 47 of file workspace/conan/dev_essential/1.4.5/dw/stable/package/aef85909f792a5a628750d25016a24323084963f/include/a_util/filesystem/filesystem.h.
enum EnumDirFlags |
Enumeration for possible listings in a directory, usable in function enumDirectory()
Enumerator | |
---|---|
ED_FILES | List files in the directory. |
ED_DIRECTORIES | List directories in the directory. |
Definition at line 37 of file workspace/conan/dev_essential/1.4.5/dw/stable/package/aef85909f792a5a628750d25016a24323084963f/include/a_util/filesystem/filesystem.h.
enum Error |
Enumerates possible error values for filesystem interaction.
Definition at line 27 of file workspace/conan/dev_essential/1.4.5/dw/stable/package/aef85909f792a5a628750d25016a24323084963f/include/a_util/filesystem/filesystem.h.
Compare content of two files.
0 | File contents are equal or p1 and p2 are the same file. |
>0 | Position of the first different character in the files. |
<0 | Comparison not possible, e.g. file does not exist or path is a directory. |
ios_base::failure | exception if cannot open the file, or try to access character after the end of file, or no character were written or error was set in ifstream. |
std::int64_t a_util::filesystem::compareFiles | ( | const Path & | p1, |
const Path & | p2, | ||
DiffOptions | options | ||
) |
Compare content of two files.
[in] | options | Options controlling the behavior of the diff operation. Supported options:
|
[in] | p1 | Path to first file. |
[in] | p2 | Path to second file. |
0 | File contents are equal or p1 and p2 are the same file. |
>0 | Position of the first different character in the files. |
<0 | Comparison not possible, e.g. file does not exist or path is a directory. |
ios_base::failure | exception if cannot open the file, or try to access character after the end of file, or no character were written or error was set in ifstream. |
bool a_util::filesystem::createDirectory | ( | const Path & | path | ) |
Create a new directory on the filesystem.
[in] | path | Path to the directory to create |
true
if the directory was created or already exists, false
otherwise Error a_util::filesystem::enumDirectory | ( | const Path & | dir_path, |
std::vector< Path > & | vec_entries, | ||
std::int32_t | flags = ED_FILES|ED_DIRECTORIES |
||
) |
List all entries in a directory.
[in] | dir_path | Path to the directory to list the entries from |
[out] | vec_entries | All entries listed in the directory |
[in] | flags | EnumDirFlags filtering what to list in the directory |
INVALID_PATH | The path does not exist or is not a directory |
GENERAL_FAILURE | Some unknown error while listing entries in the directory occurred |
OK | Entries listed successfully, with the list being copied to vec_entries |
bool a_util::filesystem::exists | ( | const Path & | path | ) |
Check whether the file or directory exists on the filesystem.
[in] | path | Path to the file or directory |
true
if the path exists, false
otherwise Path a_util::filesystem::getTempDirectory | ( | ) |
Retrieve path to the temp directory of the system.
Path getWorkingDirectory | ( | ) |
Retrieve path to the working directory of the current process.
bool a_util::filesystem::isDirectory | ( | const Path & | dir_path | ) |
Check whether the path points to a directory on the filesystem.
[in] | dir_path | Path to the directory to check |
true
if the path points to a directory, false
otherwise bool a_util::filesystem::isFile | ( | const Path & | file_path | ) |
Check whether the path points to a file on the filesystem.
[in] | file_path | Path to the file to check |
true
if the path points to a file, false
otherwise Check two paths for inequality.
[in] | lhs | Right hand side object |
[in] | rhs | Left hand side object |
true | if the paths are not equal, false otherwise |
Appends two paths, forming a new path.
[in] | a | The left path |
[in] | b | The right path |
A | new path combined from a and b (or empty, in case of an error) |
std::ostream& a_util::filesystem::operator<< | ( | std::ostream & | os, |
const Path & | p | ||
) |
Performs stream output on the path p.
[in] | os | the output stream |
[in] | p | path to print |
the | output stream |
Check two paths for equality.
[in] | lhs | Right hand side object |
[in] | rhs | Left hand side object |
true | if the paths are equal, false otherwise |
Read entire content of a text file into a string.
[in] | file_path | Path to the file to be read |
[out] | content | Destination string to be filled |
OPEN_FAILED | File could not be opened |
GENERAL_FAILURE | Seeking the file did not succeed |
IO_ERROR | Some I/O error occurred while reading the file |
OK | Content successfully read and copied to out parameter content |
Error a_util::filesystem::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.
[in] | file_path | Path to the file to be read |
[out] | vec_lines | Vector of strings with each string containing one line of the file |
bool a_util::filesystem::remove | ( | const Path & | path | ) |
Remove the file or directory pointed to by path
.
[in] | path | Path to the element to be deleted. |
true
if the element could be deleted, false
otherwise. Set the working directory.
[in] | path | Path to the new working directory |
INVALID_PATH | The path is invalid/nonexisting or a file path |
GENERAL_FAILURE | The OS failed to set the working directory |
OK | Working directory was successfully set |
Open a file in mode 'w' and write new content to it.
[in] | file_path | Path to the file to (over-)write |
[in] | content | Content to write to the file |
OPEN_FAILED | File could not be opened |
IO_ERROR | Some I/O error occurred while writing the file |
OK | Content successfully read and copied to out parameter content |