edelib
2.1.0
|
Temporary file class. More...
#include <edelib/TempFile.h>
Public Member Functions | |
TempFile () | |
~TempFile () | |
bool | create (const char *prefix, int mode=0600) |
operator bool (void) const | |
void | unlink (void) |
bool | close (void) |
void | set_auto_delete (bool v) |
void | set_no_close (bool n) |
FILE * | fstream (void) |
const char * | name (void) const |
int | handle (void) const |
int | status (void) const |
Temporary file class.
TempFile is responsible for creating unique temporary file.
TempFile behaves much as mktemp() or mkstemp() functions: you provide location with templated name, and it will try to create the one, by opening it (like mkstemp()). Templated name ends with XXXXXX. On other hand, if you do not provide XXXXXX-es at the end, TempFile will append them.
This class was greatly inspired by KTempFile from kdelibs because I had no clue how to model it ;)
TempFile | ( | ) |
Constructor. Does nothing, except setting internal values to invalid state
~TempFile | ( | ) |
Destructor. Closes file descriptor too
bool close | ( | void | ) |
Closes descriptor
bool create | ( | const char * | prefix, |
int | mode = 0600 |
||
) |
Create file and return creation status. prefix is location where file will be created, with given mode. If file could not be created at all, status() will return errno value for further inspection
FILE* fstream | ( | void | ) |
Return FILE object or NULL if create() failed
|
inline |
Return file descriptor
|
inline |
Return temporary file name. If create() failed, NULL will be returned
|
inline |
Check if create() was successfull
|
inline |
If set to true, the file will be deleted when TempFile destructor was called. Default is false
|
inline |
If set to true, the file descriptors will not be closed when destructor was called. Default is false
|
inline |
Return errno status
void unlink | ( | void | ) |
Removes the file. If file wasn't created successfully before, it will do nothing