DUECA/DUSIME
|
Create a numbered, unique, empty, writeable file, according to a format. More...
#include <UniqueFile.hxx>
Public Member Functions | |
UniqueFile () | |
Default constructor, no arguments. | |
void | open (const char *fmt, unsigned start_at=0, ios_base::openmode __mode=ios_base::out|ios_base::trunc) |
Open call for a file. | |
unsigned | getOrdinal () |
Get the sequence number. | |
const char * | getName () |
Get the file name. | |
Create a numbered, unique, empty, writeable file, according to a format.
This class is derived from the std::ofstream class. Instead of a file name it accepts a c-style format that should work with a long integer. Opening a new file with that format is attempted, with the integer running from 0 to 999 (1000 unique files). The open method is overridden, for the rest of the methods this class follows the ofstream interface.
A suggestion for the format might be "myfile%03d.ext". This would produce files with names such as myfile000.ext, myfile001.ext, myfile002.ext etcetera.
void dueca::UniqueFile::open | ( | const char * | fmt, |
unsigned | start_at = 0, | ||
ios_base::openmode | __mode = ios_base::out|ios_base::trunc ) |
Open call for a file.
fmt | c-style format |
start_at | counter start for the file name search |
__mode | file open mode. |