![]() |
LogDoctor 2.04
Parse Apache2/Nginx/IIS logs and view dinamically generated statistics
|
IOUtils. More...
Functions | |
const bool | exists (std::string_view path) |
Checks the existence of a file/folder. | |
const bool | isFile (std::string_view path) |
Checks if a path exists and points to a file. | |
const bool | checkFile (std::string_view path, const bool readable=false, const bool writable=false) |
Checks if a path exists, if it points to a file and if the user has read and/or write permissions on it. | |
const bool | isDir (std::string_view path) |
Checks if a path exists and points to a directory. | |
const bool | checkDir (std::string_view path, const bool readable=false, const bool writable=false) |
Checks if a path exists, if it points to a folder and if the user has read and/or write permissions on it. | |
const bool | makeDir (std::string_view path, std::error_code &err) noexcept(true) |
Creates a directory. | |
const bool | renameAsCopy (std::string_view path, std::error_code &err) noexcept(true) |
Renames an entry with a trailing '.copy'. | |
void | readFile (const std::string &path, std::string &content) |
Reads the content of a file. | |
void | randomLines (const std::string &path, std::vector< std::string > &lines, const size_t n_lines=16ul, const bool strip_lines=true) |
Randomly pick lines from a file. | |
void | writeOnFile (const std::string &path, std::string_view content) |
Writes a string on file. | |
IOUtils.
Utilities to work on files
const bool IOutils::checkDir | ( | std::string_view | path, |
const bool | readable = false , |
||
const bool | writable = false |
||
) |
Checks if a path exists, if it points to a folder and if the user has read and/or write permissions on it.
path | The path of the entry |
readable | Set to true to check for readability |
writable | Set to true to check for writability |
const bool IOutils::checkFile | ( | std::string_view | path, |
const bool | readable = false , |
||
const bool | writable = false |
||
) |
Checks if a path exists, if it points to a file and if the user has read and/or write permissions on it.
path | The path of the entry |
readable | Set to true to check for readability |
writable | Set to true to check for writability |
const bool IOutils::exists | ( | std::string_view | path | ) |
Checks the existence of a file/folder.
path | The path of the entry |
const bool IOutils::isDir | ( | std::string_view | path | ) |
Checks if a path exists and points to a directory.
path | The path of the entry |
const bool IOutils::isFile | ( | std::string_view | path | ) |
Checks if a path exists and points to a file.
path | The path of the entry |
|
noexcept |
Creates a directory.
path | The path of the new entry |
void IOutils::randomLines | ( | const std::string & | path, |
std::vector< std::string > & | lines, | ||
const size_t | n_lines = 16ul , |
||
const bool | strip_lines = true |
||
) |
Randomly pick lines from a file.
path | The path of the entry |
lines | Will hold the picked lines |
n_lines | The number of lines to pick |
strip_lines | Whether to strip control-characters away from the lines |
void IOutils::readFile | ( | const std::string & | path, |
std::string & | content | ||
) |
Reads the content of a file.
path | The path of the file to read from |
content | Will hold the content of the file |
|
noexcept |
Renames an entry with a trailing '.copy'.
path | The path of the entry to rename |
err | Will hold the error, if any |
void IOutils::writeOnFile | ( | const std::string & | path, |
std::string_view | content | ||
) |
Writes a string on file.
path | The path of the file to write on |
content | The string to write |