Hermes
|
Set of useful functions to manipulate files and directories. More...
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. More... | |
static std::string | basename (const std::string &path, const std::string &suffix="") |
Strips directory and suffix from filename. More... | |
static std::string | fileExtension (const std::string &filename) |
Retrieves file's extension. More... | |
static std::string | normalizePath (const std::string &path, bool with_backslash=false) |
Fixes path separators and ".." parts. More... | |
static u64 | readFile (const char *filename, char **text) |
loads contents from file More... | |
static std::vector< unsigned char > | readBinaryFile (const Path &filename) |
loads binary content from file More... | |
static std::vector< std::string > | readLines (const Path &path) |
Read file's contents separated by line breaks. More... | |
static std::string | readFile (const Path &filename) |
Read ascii contents from file. More... | |
static bool | touch (const Path &path_to_file) |
Creates an empty file or access it. More... | |
static u64 | writeFile (const Path &path, const std::vector< char > &content, bool is_binary=false) |
Writes content to file. More... | |
static u64 | writeFile (const Path &path, const std::string &content, bool is_binary=false) |
Writes content to file. More... | |
static u64 | writeLine (const Path &path, const std::string &line, bool is_binary=false) |
Writes line to path. More... | |
static u64 | appendToFile (const Path &path, const std::vector< char > &content, bool is_binary=false) |
Appends content to file. More... | |
static u64 | appendToFile (const Path &path, const std::string &content, bool is_binary=false) |
Appends content to file. More... | |
static u64 | appendLine (const Path &path, const std::string &line, bool is_binary=false) |
Appends line to file. More... | |
static bool | fileExists (const Path &path) |
Checks if file exists. More... | |
static bool | isFile (const Path &path) |
Checks if filename corresponds to a file. More... | |
static bool | isDirectory (const Path &dir_name) |
Checks if dir_name corresponds to a directory. More... | |
static std::vector< Path > | ls (const Path &path, ls_options options=ls_options::none) |
Lists files inside a directory. More... | |
static bool | mkdir (const Path &path) |
Recursively creates the path of directories. More... | |
static bool | copyFile (const Path &source, const Path &destination) |
Copy file's contents to destination file. More... | |
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. More... | |
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 |
|
static |
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 |
|
static |
Checks if dir_name corresponds to a directory.
dir_name | [in] /path/to/directory |
|
static |
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; |
|
static |
Recursively creates the path of directories.
path | path/to/directory |
|
static |
Fixes path separators and ".." parts.
path | |
with_backslash |
|
static |
loads binary content from file
filename | [in] path/to/file.ext |
|
static |
loads contents from file
filename | [in] path/to/file. |
text | [out] receives file content. |
|
static |
Read ascii contents from file.
filename | path/to/file.ext |
|
static |
Read file's contents separated by line breaks.
path |
|
static |
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 |