Back to Adaptive Vision Library website
You are here: Start » Function Reference » File System » GenerateFileName
This is Filter Equivalent. This function may be present in generated code, but should not be used in hand-written code.
Generates consecutive file names, e.g. for saving series of images
Syntax
void avl::GenerateFileName ( GenerateFileNameState& ioState, const atl::Directory& inDirectory, const atl::String& inPattern, atl::File& outFile )
Parameters
Name | Type | Default | Description | |
---|---|---|---|---|
ioState | GenerateFileNameState& | Object used to maintain state of the function. | ||
inDirectory | const Directory& | \".\" | Input directory | |
inPattern | const String& | \"file_$_####.txt\" | File name pattern, $ is replaced by date, # is replaced by number | |
outFile | File& | Generated file name |
Description
Working with GenerateFileName
Start with defining input directory in inDirectory, where the files will be stored. Then, define the pattern of file names. It should contain:
- '#' signs, which will be replaced with number of image (required). Files are enumerated from 0.
- '$' signs, which will be replaced with current date in form of YYYY_MM_DD_hh_mm_ss (optional).
Examples
Examples of patterns and resulting file names are shown in the table below:
Pattern |
Resulting file name |
Explanation |
file_$_####.txt | file_2017_12_15_09_44_03_0000.txt | 2017_12_15_09_44_03 is the date and time of the generation of the file name. The last number - 0000 - indicates, that the name is generated for the first file in the sequence. |
file####.txt | file0021.txt | The number 0021 indicates, that the name is generated for the 22nd file in the sequence. |
$_##.txt | 2017_12_15_09_44_03_01.txt | 2017_12_15_09_44_03 is the date and time of the generation of the file name. The last number - 01 - indicates, that the name is generated for the second file in the sequence. |
Errors
Error type | Description |
---|---|
DomainError | Given directory does not exist in GenerateFileName. |
DomainError | Exactly one series of # characters is required in pattern in GenerateFileName. |
See Also
- FileAttributes – Provides information about file, e.g. size, modification time
- SaveImage – Saves an image to a file.