Manages a tree of files, save and cleanup.
More...
#include <tsFileTreeManager.h>
Manages a tree of files, save and cleanup.
◆ FileTreeManager()
| ts::FileTreeManager::FileTreeManager |
( |
Report & |
report | ) |
|
Constructor.
- Parameters
-
| [in,out] | report | Where to report errors and messages. |
◆ setRootDirectory()
| void ts::FileTreeManager::setRootDirectory |
( |
const fs::path & |
root | ) |
|
|
inline |
Set the root directory of files to save and cleanup.
If no root directory is specified, no file can be saved. By default, there is no initial root directory.
- Parameters
-
◆ setDeleteAfter()
template<class Rep , class Period >
| void ts::FileTreeManager::setDeleteAfter |
( |
cn::duration< Rep, Period > |
age | ) |
|
|
inline |
Set the maximum retention time of saved files.
- Parameters
-
| [in] | age | The maximum duration of a file, after being saved. When zero (the initial default), files are never deleted. |
◆ cleanupOldFiles()
Force a cleanup of all files to delete.
- Parameters
-
| [in] | current | Hypothetical current UTC time. By default, use the current UTC time. This parameter can be used to simulate a later time and force deletion of files. |
- Returns
- True on success, false on error.
◆ saveFile()
Save a file into the file tree.
- Parameters
-
| [in] | content | Binary content to save. |
| [in] | filename | A relative path of the file to save. The path is sanitized first:
- All invalid characters (for the current filesystem) are replaced with replacement.
- All attempts to move upward in the file system hierarchy ("..") are removed.
- If filename starts with an URI scheme, it is removed.
- If the file path is absolute, it is relocated under the root directory of the file tree.
|
| [in] | replacement | The replacement character for invalid characters. |
| [in] | current | Hypothetical current UTC time. By default, use the current UTC time. This parameter can be used to simulate a later time and force deletion of files. |
- Returns
- True on success, false on error.
The documentation for this class was generated from the following file: