|
Hermes
|
Set of useful functions to manipulate files and directories. More...
#include <file_system.h>
Static Public Member Functions | |
| static std::vector< std::string > | basename (const std::vector< std::string > &paths, const std::string &suffix="") |
| Strips directory and suffix from filenames. | |
| static std::string | basename (const std::string &path, const std::string &suffix="") |
| Strips directory and suffix from filename. | |
| static std::string | fileExtension (const std::string &filename) |
| Retrieves file's extension. | |
| static std::string | normalizePath (const std::string &path, bool with_backslash=false) |
| Fixes path separators and ".." parts. | |
| static u64 | readFile (const char *filename, char **text) |
| loads contents from file | |
| static std::vector< unsigned char > | readBinaryFile (const Path &filename) |
| loads binary content from file | |
| static std::vector< std::string > | readLines (const Path &path) |
| Read file's contents separated by line breaks. | |
| static std::string | readFile (const Path &filename) |
| Read ascii contents from file. | |
| static bool | touch (const Path &path_to_file) |
| Creates an empty file or access it. | |
| static u64 | writeFile (const Path &path, const std::vector< char > &content, bool is_binary=false) |
| Writes content to file. | |
| static u64 | writeFile (const Path &path, const std::string &content, bool is_binary=false) |
| Writes content to file. | |
| static u64 | writeLine (const Path &path, const std::string &line, bool is_binary=false) |
| Writes line to path. | |
| static u64 | appendToFile (const Path &path, const std::vector< char > &content, bool is_binary=false) |
| Appends content to file. | |
| static u64 | appendToFile (const Path &path, const std::string &content, bool is_binary=false) |
| Appends content to file. | |
| static u64 | appendLine (const Path &path, const std::string &line, bool is_binary=false) |
| Appends line to file. | |
| static bool | fileExists (const Path &path) |
| Checks if file exists. | |
| static bool | isFile (const Path &path) |
| Checks if filename corresponds to a file. | |
| static bool | isDirectory (const Path &dir_name) |
| Checks if dir_name corresponds to a directory. | |
| static std::vector< Path > | ls (const Path &path, ls_options options=ls_options::none) |
| Lists files inside a directory. | |
| static bool | mkdir (const Path &path) |
| Recursively creates the path of directories. | |
| static bool | copyFile (const Path &source, const Path &destination) |
| Copy file's contents to destination file. | |
| static std::vector< Path > | find (const Path &path, const std::string &pattern, find_options options=find_options::none) |
| Search for files in a directory hierarchy. | |
Set of useful functions to manipulate files and directories.
|
static |
Appends line to file.
| path | |
| line | |
| is_binary |
|
static |
Appends content to file.
| path | [in] path/to/file.ext |
| content | |
| is_binary | [in | default = false] write in binary mode |
|
static |
Appends content to file.
| path | [in] path/to/file.ext |
| content | |
| is_binary | [in | default = false] write in binary mode |
|
static |
Strips directory and suffix from filename.
| path | [in] /path/to/filename<suffix> |
| suffix | [in | optional] |
|
static |
Strips directory and suffix from filenames.
| paths | [in] {/path/to/filename1suffix,...} |
| suffix | [in | optional] |
Copy file's contents to destination file.
| source | |
| destination |
Checks if file exists.
| path | /path/to/file.ext |
|
static |
Retrieves file's extension.
| filename | path/to/filename.extension |
|
static |
Search for files in a directory hierarchy.
| path | root directory |
| pattern | [in | ""] regular expression |
| options | [in | find_options::none] none = default behaviour; recursive = recursively search on directories bellow path |
Checks if dir_name corresponds to a directory.
| dir_name | [in] /path/to/directory |
Checks if filename corresponds to a file.
| path | /path/to/file.ext |
|
static |
Lists files inside a directory.
| path | [in] path/to/directory |
| options | [in | ls_options::none] options_ based on ls command: none = the default behaviour; sort = sort paths following lexicographical order; reverse_sort = sort in reverse order; directories = list only directories; files = list only files; group_directories_first = directories come first in sorting; recursive = list directories contents; |
Recursively creates the path of directories.
| path | path/to/directory |
|
static |
Fixes path separators and ".." parts.
| path | |
| with_backslash |
loads binary content from file
| filename | [in] path/to/file.ext |
loads contents from file
| filename | [in] path/to/file. |
| text | [out] receives file content. |
Read ascii contents from file.
| filename | path/to/file.ext |
Read file's contents separated by line breaks.
| path |
Creates an empty file or access it.
| path_to_file | valid file path |
|
static |
Writes content to file.
| path | [in] path/to/file.ext |
| content | |
| is_binary | [in | default = false] write in binary mode |
|
static |
Writes content to file.
| path | [in] path/to/file.ext |
| content | |
| is_binary | [in | default = false] write in binary mode |
|
static |
Writes line to path.
| path | |
| line | |
| is_binary |