IOUtils.
More...
#include <io.h>
|
static const bool | exists (const std::string &path) |
| Checks the existence of a file/folder. More...
|
|
static const bool | isFile (const std::string &path) |
| Checks if a path exists and points to a file. More...
|
|
static const bool | isDir (const std::string &path) |
| Checks if a path exists and points to a directory. More...
|
|
static const bool | checkFile (const std::string &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. More...
|
|
static const bool | checkDir (const std::string &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. More...
|
|
static const bool | makeDir (const std::string &path) noexcept(true) |
| Creates a directory. More...
|
|
static const bool | renameAsCopy (const std::string &path) noexcept(true) |
| Renames an entry with a trailing '.copy'. More...
|
|
static void | randomLines (const std::string &path, std::vector< std::string > &lines, const int &n_lines=16, const bool &strip_lines=true) |
| Randomly pick lines from a file. More...
|
|
static void | readFile (const std::string &path, std::string &content) |
| Reads the content of a file. More...
|
|
static void | writeOnFile (const std::string &path, const std::string &content) |
| Writes a string on file. More...
|
|
IOUtils.
Utilities to work on files
◆ checkDir()
const bool IOutils::checkDir |
( |
const std::string & |
path, |
|
|
const bool & |
readable = false , |
|
|
const bool & |
writable = false |
|
) |
| |
|
static |
Checks if a path exists, if it points to a folder and if the user has read and/or write permissions on it.
- Parameters
-
path | The path of the entry |
readable | Set to true to check for readability |
writable | Set to true to check for writability |
- Returns
- The result of the checks
◆ checkFile()
const bool IOutils::checkFile |
( |
const std::string & |
path, |
|
|
const bool & |
readable = false , |
|
|
const bool & |
writable = false |
|
) |
| |
|
static |
Checks if a path exists, if it points to a file and if the user has read and/or write permissions on it.
- Parameters
-
path | The path of the entry |
readable | Set to true to check for readability |
writable | Set to true to check for writability |
- Returns
- The result of the checks
◆ exists()
const bool IOutils::exists |
( |
const std::string & |
path | ) |
|
|
static |
Checks the existence of a file/folder.
- Parameters
-
path | The path of the entry |
- Returns
- The result of the check
◆ isDir()
const bool IOutils::isDir |
( |
const std::string & |
path | ) |
|
|
static |
Checks if a path exists and points to a directory.
- Parameters
-
path | The path of the entry |
- Returns
- The result of the checks
◆ isFile()
const bool IOutils::isFile |
( |
const std::string & |
path | ) |
|
|
static |
Checks if a path exists and points to a file.
- Parameters
-
path | The path of the entry |
- Returns
- The result of the check
◆ makeDir()
const bool IOutils::makeDir |
( |
const std::string & |
path | ) |
|
|
staticnoexcept |
Creates a directory.
- Parameters
-
path | The path of the new entry |
- Returns
- Wheter the operation was successful or not
◆ randomLines()
void IOutils::randomLines |
( |
const std::string & |
path, |
|
|
std::vector< std::string > & |
lines, |
|
|
const int & |
n_lines = 16 , |
|
|
const bool & |
strip_lines = true |
|
) |
| |
|
static |
Randomly pick lines from a file.
- Parameters
-
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 |
◆ readFile()
void IOutils::readFile |
( |
const std::string & |
path, |
|
|
std::string & |
content |
|
) |
| |
|
static |
Reads the content of a file.
- Parameters
-
path | The path of the file to read from |
content | Will hold the content of the file |
◆ renameAsCopy()
const bool IOutils::renameAsCopy |
( |
const std::string & |
path | ) |
|
|
staticnoexcept |
Renames an entry with a trailing '.copy'.
- Parameters
-
path | The path of the entry to rename |
- Returns
- Wheter the operation was successful or not
◆ writeOnFile()
void IOutils::writeOnFile |
( |
const std::string & |
path, |
|
|
const std::string & |
content |
|
) |
| |
|
static |
Writes a string on file.
- Parameters
-
path | The path of the file to write on |
content | The string to write |
The documentation for this class was generated from the following files:
- logdoctor/utilities/io.h
- logdoctor/utilities/io.cpp