nidas v1.2.3
|
A description of a set of output files, consisting of a directory name and a file name format containing UNIX strftime conversion specifiers, like Y, m, etc. More...
#include <FileSet.h>
Public Member Functions | |
FileSet () | |
constructor | |
FileSet (const FileSet &x) | |
Copy constructor. | |
FileSet & | operator= (const FileSet &x) |
Assignment operator. | |
virtual FileSet * | clone () const |
Virtual constructor. | |
virtual | ~FileSet () |
Destructor. | |
virtual void | setDir (const std::string &val) |
Set directory portion of file path. | |
virtual const std::string & | getDir () |
int | getFd () const |
bool | isNewFile () const |
virtual void | setFileName (const std::string &val) |
Set file name portion of file path. | |
virtual const std::string & | getFileName () |
virtual const std::string & | getPath () |
Get the full path, the concatenation of getDir() and getFileName(). | |
virtual void | addFileName (const std::string &val) |
void | setFileLengthSecs (int val) |
Set/get the file length in seconds. | |
int | getFileLengthSecs () const |
virtual UTime | createFile (UTime tfile, bool exact) |
Create a new file, with a name formed from a time. | |
void | setStartTime (const UTime &val) |
UTime | getStartTime () const |
void | setEndTime (const UTime &val) |
UTime | getEndTime () const |
const std::string & | getCurrentName () const |
Get name of current file. | |
virtual void | closeFile () |
Closes any file currently open. | |
virtual void | openFileForWriting (const std::string &filename) |
Open a new file for writing. | |
void | openNextFile () |
Open the next file to be read. | |
virtual size_t | read (void *buf, size_t count) |
Read from current file. | |
virtual size_t | write (const void *buf, size_t count) |
Write to current file. | |
virtual size_t | write (const struct iovec *iov, int iovcnt) |
void | checkPathFormat (const UTime &t1, const UTime &t2) |
Check that any date or time descriptors, e.g. | |
std::list< std::string > | matchFiles (const UTime &t1, const UTime &t2) |
long long | getFileSize () const |
int | getLastErrno () const |
Get last error value. | |
void | setKeepOpening (bool keepopening) |
Set whether the FileSet should keep going to the next file when an error happens opening a file. | |
bool | keepOpening () |
Static Public Member Functions | |
static void | createDirectory (const std::string &name, mode_t mode) |
static std::string | getDirPortion (const std::string &path) |
Utility function to return the directory portion of a file path. | |
static std::string | getFilePortion (const std::string &path) |
Utility function to return the file portion of a file path. | |
static std::string | makePath (const std::string &dir, const std::string &file) |
Utility function to create a full path name from a directory and file portion. | |
Static Public Attributes | |
static const char | pathSeparator = '/' |
Protected Member Functions | |
std::string | formatName (const UTime &t1) |
Static Protected Member Functions | |
static void | replaceChars (std::string &in, const std::string &pat, const std::string &rep) |
Protected Attributes | |
const std::time_put< char > & | _timeputter |
bool | _newFile |
int | _lastErrno |
This value can get set by getFileSize() which is a const method. | |
int | _fd |
bool | _keepopening |
Private Member Functions | |
void | initialize () |
Private Attributes | |
std::string | _dir |
std::string | _filename |
std::string | _currname |
std::string | _fullpath |
UTime | _startTime |
UTime | _endTime |
std::list< std::string > | _fileset |
std::list< std::string >::iterator | _fileiter |
bool | _initialized |
long long | _fileLength |
File length, in microseconds. | |
A description of a set of output files, consisting of a directory name and a file name format containing UNIX strftime conversion specifiers, like Y, m, etc.
Typically this class is used by an archive method.
FileSet::FileSet | ( | ) |
constructor
Referenced by clone().
FileSet::FileSet | ( | const FileSet & | x | ) |
Copy constructor.
Only permissable before it is opened.
|
virtual |
Destructor.
Closes current file, ignoring possible IOException if the file isn't open.
References closeFile().
|
inlinevirtual |
References _fileset.
Referenced by nidas::core::FileSet::addFileName().
Check that any date or time descriptors, e.g.
"%y", "%m", in the full file path string are in the correct order, so that a default lexical sort will sort the file path names in time order. The descriptors in the path must be in decreasing time-interval order, e.g. year before month, month before day, etc.
IOException |
References _fullpath, and USECS_PER_DAY.
Referenced by matchFiles().
|
virtual |
|
virtual |
Closes any file currently open.
The base implementation closes the file descriptor. Subclasses override this method to close alternate resources.
IOException |
References _currname, _fd, DLOG, and fd.
Referenced by nidas::core::FileSet::close(), createFile(), openNextFile(), operator=(), read(), and ~FileSet().
|
static |
IOException |
References createDirectory(), DLOG, getDirPortion(), and ILOG.
Referenced by createDirectory(), and createFile().
Create a new file, with a name formed from a time.
Create a file using a time to create the name.
tfile | Time to use when creating file name. |
exact | Use exact time when creating file name, else the time is truncated by getFileLengthSecs. |
IOException |
Return the time of the next file.
References _currname, _fileLength, _fullpath, _lastErrno, _newFile, closeFile(), createDirectory(), createFile(), DLOG, ftime(), getDirPortion(), ILOG, openFileForWriting(), nidas::util::UTime::toUsecs(), USECS_PER_SEC, and WLOG.
Referenced by nidas::core::FileSet::createFile(), and createFile().
|
protected |
References _fullpath.
Referenced by initialize().
|
inline |
Get name of current file.
References _currname.
Referenced by nidas::core::FileSet::getCurrentName().
|
inlinevirtual |
References _dir.
Referenced by setFileName().
|
static |
Utility function to return the directory portion of a file path.
If the directory portion is empty, returns ".". Uses pathSeparator to determine directory and file portion.
References pathSeparator.
Referenced by createDirectory(), createFile(), and matchFiles().
|
inline |
References _fd.
Referenced by nidas::core::FileSet::getFd().
|
inline |
References _fileLength, and USECS_PER_SEC.
Referenced by nidas::core::FileSet::getFileLengthSecs().
|
inlinevirtual |
|
static |
Utility function to return the file portion of a file path.
Uses pathSeparator to determine directory and file portion.
References pathSeparator.
Referenced by matchFiles().
long long FileSet::getFileSize | ( | ) | const |
IOException |
References _currname, _fd, and _lastErrno.
Referenced by nidas::core::FileSet::getFileSize().
|
inline |
Get last error value.
Should be 0. Currently only supported for an output file, to be queried by a system status thread.
References _lastErrno.
Referenced by nidas::core::FileSet::getLastErrno().
|
inlinevirtual |
Get the full path, the concatenation of getDir() and getFileName().
References _fullpath.
Referenced by nidas::core::FileSet::setDir(), and nidas::core::FileSet::setFileName().
|
inline |
References _startTime.
Referenced by nidas::core::FileSet::getEndTime(), and nidas::core::FileSet::getStartTime().
|
private |
References _endTime, _fileiter, _fileLength, _fileset, _fullpath, _initialized, _startTime, DLOG, formatName(), matchFiles(), nidas::util::UTime::toUsecs(), and USECS_PER_DAY.
Referenced by openNextFile().
|
inline |
References _newFile.
Referenced by nidas::core::FileSet::isNewInput().
|
inline |
References _keepopening.
Referenced by nidas::core::FileSet::keepOpening().
|
static |
Utility function to create a full path name from a directory and file portion.
If the directory portion is an empty string, or ".", then the result path will have no directory portion.
References pathSeparator.
Referenced by matchFiles(), setDir(), and setFileName().
IOException |
References _fullpath, checkPathFormat(), DLOG, ftime(), getDirPortion(), getFilePortion(), makePath(), replaceChars(), USECS_PER_DAY, and USECS_PER_HOUR.
Referenced by initialize().
|
virtual |
Open a new file for writing.
The filename
is the path for the new file as generated from the filename template and a time. The base implementation calls open64() and sets the file descriptor.
IOException |
References _fd, and _lastErrno.
Referenced by createFile().
void FileSet::openNextFile | ( | ) |
Open the next file to be read.
IOException |
References _currname, _fd, _fileiter, _fileset, _initialized, _keepopening, _newFile, closeFile(), DLOG, ELOG, ILOG, and initialize().
Referenced by read().
Assignment operator.
Only permissable before it is opened.
References _currname, _dir, _endTime, _fileiter, _fileLength, _filename, _fileset, _fullpath, _initialized, _keepopening, _lastErrno, _newFile, _startTime, and closeFile().
|
virtual |
Read from current file.
IOException |
References _currname, _fd, _newFile, closeFile(), openNextFile(), and read().
Referenced by read(), and nidas::core::FileSet::read().
|
staticprotected |
Referenced by matchFiles().
|
virtual |
Set directory portion of file path.
This may contain strftime conversion specifiers, like Y in order to put a year in the directory name.
References _dir, _fullpath, getFileName(), and makePath().
Referenced by nidas::core::FileSet::setDir().
|
inline |
References _endTime.
Referenced by nidas::core::FileSet::setEndTime().
|
inline |
Set/get the file length in seconds.
0 means unlimited.
References _fileLength, and USECS_PER_SEC.
Referenced by nidas::core::FileSet::setFileLengthSecs().
|
virtual |
Set file name portion of file path.
This can contain strftime conversion specifiers. FileSet inserts the pathSeparator between the directory and the file name when creating the full file path string. Otherwise there is no distinction between the directory and file portion.
References _filename, _fullpath, getDir(), and makePath().
Referenced by nidas::core::FileSet::setFileName().
|
inline |
Set whether the FileSet should keep going to the next file when an error happens opening a file.
References _keepopening.
Referenced by nidas::core::FileSet::setKeepOpening().
|
inline |
References _startTime.
Referenced by nidas::core::FileSet::setStartTime().
|
virtual |
IOException |
References _currname, _fd, and _lastErrno.
|
virtual |
Write to current file.
IOException |
References _currname, _fd, _lastErrno, and write().
Referenced by nidas::core::FileSet::write(), write(), and nidas::core::FileSet::write().
|
private |
Referenced by closeFile(), createFile(), getCurrentName(), getFileSize(), openNextFile(), operator=(), read(), write(), and write().
|
private |
Referenced by getDir(), operator=(), and setDir().
|
private |
Referenced by getEndTime(), initialize(), operator=(), and setEndTime().
|
protected |
Referenced by closeFile(), getFd(), getFileSize(), openFileForWriting(), openNextFile(), read(), write(), and write().
|
private |
Referenced by initialize(), openNextFile(), and operator=().
|
private |
File length, in microseconds.
Referenced by createFile(), getFileLengthSecs(), initialize(), operator=(), and setFileLengthSecs().
|
private |
Referenced by getFileName(), operator=(), and setFileName().
|
private |
Referenced by addFileName(), initialize(), openNextFile(), and operator=().
|
private |
Referenced by checkPathFormat(), createFile(), formatName(), getPath(), initialize(), matchFiles(), operator=(), setDir(), and setFileName().
|
private |
Referenced by initialize(), openNextFile(), and operator=().
|
protected |
Referenced by keepOpening(), openNextFile(), operator=(), and setKeepOpening().
|
mutableprotected |
This value can get set by getFileSize() which is a const method.
Referenced by createFile(), getFileSize(), getLastErrno(), openFileForWriting(), operator=(), write(), and write().
|
protected |
Referenced by createFile(), isNewFile(), openNextFile(), operator=(), and read().
|
private |
Referenced by getStartTime(), initialize(), operator=(), and setStartTime().
|
protected |
|
static |
Referenced by getDirPortion(), getFilePortion(), and makePath().