|
Dev Essential
|
Serves as component for path and filesystem functionality. More...
Classes | |
| class | Path |
| class | PathException |
| Exception class used by Path methods. 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 } |
Functions | |
| Path | getTempDirectory () |
| Path | getWorkingDirectory () |
| Error | setWorkingDirectory (const Path &path) |
| Error | readTextFile (const Path &file_path, std::string &content) |
| Error | readTextLines (const Path &file_path, std::vector< std::string > &vec_lines) |
| Error | writeTextFile (const Path &file_path, const std::string &content) |
| Error | enumDirectory (const Path &dir_path, std::vector< Path > &vec_entries, std::int32_t flags=ED_FILES|ED_DIRECTORIES) |
| bool | exists (const Path &path) |
| bool | createDirectory (const Path &path) |
| bool | isFile (const Path &file_path) |
| bool | isDirectory (const Path &dir_path) |
| bool | remove (const Path &path) |
| bool | rename (const Path &path, const Path &new_path) |
| std::int64_t | compareFiles (const Path &p1, const Path &p2) |
| std::int64_t | compareFiles (const Path &p1, const Path &p2, DiffOptions options) |
| bool | operator== (const Path &lhs, const Path &rhs) |
| bool | operator!= (const Path &lhs, const Path &rhs) |
| std::ostream & | operator<< (std::ostream &os, const Path &p) |
| Path | operator+ (const Path &a, const Path &b) |
Serves as component for path and filesystem functionality.
|
strong |
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. |
Enumerates possible error values for filesystem interaction.
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 ) |
| [in] | options | Options controlling the behavior of the diff operation. Supported options:
|
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. |
| 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 a_util::filesystem::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 |