|
DCMTK Version 3.6.9
OFFIS DICOM Toolkit
|
this class manages the lifetime of a temporary file. More...
Public Member Functions | |
| OFTempFile (unsigned int flags=O_RDWR, const OFString &dir="", const OFString &prefix="", const OFString &postfix=".tmp") | |
| default constructor, create a temporary file with a random name. | |
| ~OFTempFile () | |
| destructor. Deletes the temporary file, if one was created | |
| OFCondition | getStatus () const |
| gets the error status of this class. If this is bad, no file was created | |
| const char * | getFilename () const |
| gets the filename of the temporary file. | |
| int | getFileHandle () const |
| gets the file descriptor of the temporary file. | |
| void | stealFile (OFBool dontCloseHandle=OFFalse) |
| steals the created temporary file from this class. | |
Static Public Member Functions | |
| static OFCondition | createFile (OFString &fileName, int *fd_out=NULL, unsigned int flags=O_RDWR, const OFString &dir="", const OFString &prefix="", const OFString &postfix=".tmp") |
| Create a new temporary file. | |
| static void | getTempPath (OFString &sPath) |
| Return the system-specific path for storing temporary files. | |
Private Member Functions | |
| OFTempFile (const OFTempFile &) | |
| private undefined copy constructor | |
| OFTempFile & | operator= (const OFTempFile &) |
| private undefined assignment operator | |
Private Attributes | |
| OFCondition | m_status |
| Status for this class, if EC_Normal then we are managing a temporary file. | |
| OFString | m_fileName |
| Path to the temporary file that we are managing, empty string if none. | |
| int | m_fileHandle |
| File handle for our file, -1 if we don't have any file. | |
this class manages the lifetime of a temporary file.
The file will be created when needed and automatically be deleted by the destructor.
| OFTempFile::OFTempFile | ( | unsigned int | flags = O_RDWR, |
| const OFString & | dir = "", | ||
| const OFString & | prefix = "", | ||
| const OFString & | postfix = ".tmp" ) |
default constructor, create a temporary file with a random name.
The file will be automatically deleted.
| flags | additional flags to pass to open() as its third argument. |
| dir | the directory in which the file should be created. The default is a directory suitable for temporary files. |
| prefix | this string is prepended to the name of the temporary file. |
| postfix | this string is appended to the name of the temporary file. |
Referenced by OFTempFile(), and operator=().
|
static |
Create a new temporary file.
| fileName | after this call, this will contain the name of the file that was created |
| fd_out | if not NULL, this will be set to a file descriptor for this file |
| flags | additional flags to pass to open() as its third argument |
| dir | the directory in which the file should be created. The default is a directory suitable for temporary files. |
| prefix | this string is prepended to the name of the temporary file. |
| postfix | this string is appended to the name of the temporary file. |
|
inline |
gets the file descriptor of the temporary file.
If no temporary file was created, this will return -1. The returned fd is still owned by this class and will be closed later.
References m_fileHandle.
|
inline |
gets the filename of the temporary file.
If no temporary file was created, this will return an empty string.
References m_fileName.
|
static |
Return the system-specific path for storing temporary files.
| sPath | will be set to the path on return. |
| void OFTempFile::stealFile | ( | OFBool | dontCloseHandle = OFFalse | ) |
steals the created temporary file from this class.
This means that the file won't be deleted. However, by default the file handle is closed.
| dontCloseHandle | if true, the file handle is not closed. |