KSaveFile Class Reference
The KSaveFile class has been made to write out changes to an existing file atomically. More...
#include <ksavefile.h>
Public Methods | |
KSaveFile (const QString &filename, int mode=0666) | |
Creates a new KSaveFile with the given file name. | |
~KSaveFile () | |
The destructor closes the file. | |
int | status () const |
Returns the status of the file based on errno. | |
QString | name () const |
The name of the file as passed to the constructor. | |
int | handle () const |
An integer file descriptor open for writing to the file. | |
FILE * | fstream () |
A FILE* stream open for writing to the file. | |
QFile * | file () |
A QFile* open for writing to the file. | |
QTextStream * | textStream () |
A QTextStream* open for writing to the file. | |
QDataStream * | dataStream () |
A QDataStream* open for writing to the file. | |
void | abort () |
Aborts the write operation and removes any intermediate files This implies a close. | |
bool | close () |
Closes the file and makes the changes definitive. |
Detailed Description
The KSaveFile class has been made to write out changes to an existing file atomically.This means that EITHER: a) All changes have been written successfully to the file.
b) Some error occured, no changes have been written whatsoever and the old file is still in place.
Definition at line 41 of file ksavefile.h.
Constructor & Destructor Documentation
|
Creates a new KSaveFile with the given file name.
Definition at line 41 of file ksavefile.cpp. References KTempFile::create(), QString::fromLatin1(), and KTempFile::setError(). |
|
The destructor closes the file.
Definition at line 60 of file ksavefile.cpp. References close(). |
Member Function Documentation
|
Returns the status of the file based on errno. (see errno.h) 0 means OK. You should check the status after object creation to check whether a file could be created in the first place. You may check the status after closing the file to verify that the file has indeed been written correctly.
Definition at line 67 of file ksavefile.h. References KTempFile::status(). Referenced by KPalette::save(), and KConfigINIBackEnd::writeConfigFile(). |
|
The name of the file as passed to the constructor.
Definition at line 66 of file ksavefile.cpp. |
|
An integer file descriptor open for writing to the file.
Definition at line 82 of file ksavefile.h. References KTempFile::handle(). Referenced by KConfigINIBackEnd::writeConfigFile(). |
|
A FILE* stream open for writing to the file.
Definition at line 90 of file ksavefile.h. References KTempFile::fstream(). Referenced by KConfigINIBackEnd::writeConfigFile(). |
|
A QFile* open for writing to the file.
Definition at line 98 of file ksavefile.h. References KTempFile::file(). |
|
A QTextStream* open for writing to the file.
Definition at line 106 of file ksavefile.h. References KTempFile::textStream(). Referenced by KPalette::save(). |
|
A QDataStream* open for writing to the file.
Definition at line 114 of file ksavefile.h. References KTempFile::dataStream(). |
|
Aborts the write operation and removes any intermediate files This implies a close.
Definition at line 72 of file ksavefile.cpp. References KTempFile::close(), and KTempFile::unlink(). |
|
Closes the file and makes the changes definitive. Returns 'true' is successful, or 'false' if an error has occured. See status() for details about errors.
Definition at line 79 of file ksavefile.cpp. References KTempFile::close(), QString::isEmpty(), KTempFile::name(), QDir::rename(), KTempFile::setError(), and KTempFile::unlink(). Referenced by KPalette::save(), KConfigINIBackEnd::writeConfigFile(), and ~KSaveFile(). |
The documentation for this class was generated from the following files: