TSDuck v3.40-4033
MPEG Transport Stream Toolkit
|
Generate file names based on counter or dates and time. More...
#include <tsFileNameGenerator.h>
Public Member Functions | |
FileNameGenerator ()=default | |
Constructor. | |
void | initCounter (const fs::path &name_template, size_t initial_counter=0, size_t counter_width=6) |
Reinitialize the file name generator in counter mode. | |
void | initDateTime (const fs::path &name_template, int fields=Time::DATETIME) |
Reinitialize the file name generator in date and time mode. | |
fs::path | newFileName () |
Generate a new file name. | |
fs::path | newFileName (const Time &time) |
Generate a new file name with a specific date and time. | |
Generate file names based on counter or dates and time.
An instance of this class is used when an application needs to generate multiple files based on a naming pattern and a counter or date and time.
A name template is "base.ext". A number is automatically added to the name part so that successive files receive distinct names. Example: if the specified file name is base.ext, the various files are named base-000000.ext, base-000001.ext, etc. If the specified template already contains trailing digits, this unmodified name is used for the first file. Then, the integer part is incremented. Example: if the specified file name is base-027.ext, the various files are named base-027.ext, base-028.ext, etc.
Based on template "base.ext", the file names are base-YYYYMMDD-hhmmssmmm.ext where the date and time fields are optional, base on a ts::Time::FieldMask value.
|
default |
Constructor.
The initial state is counter mode with empty file template.
void ts::FileNameGenerator::initCounter | ( | const fs::path & | name_template, |
size_t | initial_counter = 0 , |
||
size_t | counter_width = 6 |
||
) |
Reinitialize the file name generator in counter mode.
[in] | name_template | File name template. |
[in] | initial_counter | Initial value of the counter. Ignored if name_template already contains a counter value. |
[in] | counter_width | Width of the counter field in the file name. Ignored if name_template already contains a counter value. |
void ts::FileNameGenerator::initDateTime | ( | const fs::path & | name_template, |
int | fields = Time::DATETIME |
||
) |
Reinitialize the file name generator in date and time mode.
[in] | name_template | File name template. |
[in] | fields | List of date and time fields to include in the file name. Ignored if name_template already contains a date and time value. |
fs::path ts::FileNameGenerator::newFileName | ( | ) |
Generate a new file name.
In counter mode, the counter is incremented in the file name. In date and time mode, the current local time is used.
fs::path ts::FileNameGenerator::newFileName | ( | const Time & | time | ) |
Generate a new file name with a specific date and time.
[in] | time | The reference time to use in date and time mode. Ignored in counter mode. |