TSDuck v3.40-4033
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::FileNameGenerator Class Reference

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.
 

Detailed Description

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.

Counter pattern

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.

Date & time pattern

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.

Constructor & Destructor Documentation

◆ FileNameGenerator()

ts::FileNameGenerator::FileNameGenerator ( )
default

Constructor.

The initial state is counter mode with empty file template.

Member Function Documentation

◆ initCounter()

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.

Parameters
[in]name_templateFile name template.
[in]initial_counterInitial value of the counter. Ignored if name_template already contains a counter value.
[in]counter_widthWidth of the counter field in the file name. Ignored if name_template already contains a counter value.

◆ initDateTime()

void ts::FileNameGenerator::initDateTime ( const fs::path &  name_template,
int  fields = Time::DATETIME 
)

Reinitialize the file name generator in date and time mode.

Parameters
[in]name_templateFile name template.
[in]fieldsList of date and time fields to include in the file name. Ignored if name_template already contains a date and time value.
See also
Time::FieldMask

◆ newFileName() [1/2]

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.

Returns
A new file name.

◆ newFileName() [2/2]

fs::path ts::FileNameGenerator::newFileName ( const Time time)

Generate a new file name with a specific date and time.

Parameters
[in]timeThe reference time to use in date and time mode. Ignored in counter mode.
Returns
A new file name.

The documentation for this class was generated from the following file: