KSaveFile Class Reference
The KSaveFile class has been made to write out changes to an existing file atomically. More...
#include <ksavefile.h>
Collaboration diagram for KSaveFile:

Public Member Functions | |
KSaveFile (const QString &filename, int mode=0666) | |
~KSaveFile () | |
int | status () const |
QString | name () const |
int | handle () const |
FILE * | fstream () |
QFile * | file () |
QTextStream * | textStream () |
QDataStream * | dataStream () |
void | abort () |
bool | close () |
Static Public Member Functions | |
bool | backupFile (const QString &filename, const QString &backupDir=QString::null, const QString &backupExtension=QString::fromLatin1("~")) |
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 occurred, 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 43 of file ksavefile.cpp. References KTempFile::create(), KTempFile::handle(), KSaveFile(), and KTempFile::setError(). Referenced by KSaveFile(). |
|
The destructor closes the file. You might want to call close() explicitely though, to test whether it worked. Definition at line 87 of file ksavefile.cpp. References KTempFile::bOpen, and 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 68 of file ksavefile.h. Referenced by KPalette::save(), and KConfigINIBackEnd::writeConfigFile(). |
|
The name of the file as passed to the constructor.
Definition at line 94 of file ksavefile.cpp. |
|
An integer file descriptor open for writing to the file.
Definition at line 83 of file ksavefile.h. Referenced by KConfigINIBackEnd::writeConfigFile(). |
|
A FILE* stream open for writing to the file.
Definition at line 91 of file ksavefile.h. Referenced by KConfigINIBackEnd::writeConfigFile(). |
|
A QFile* open for writing to the file.
Definition at line 99 of file ksavefile.h. |
|
A QTextStream* open for writing to the file.
Definition at line 107 of file ksavefile.h. Referenced by KPalette::save(). |
|
A QDataStream* open for writing to the file.
Definition at line 115 of file ksavefile.h. |
|
Aborts the write operation and removes any intermediate files This implies a close.
Definition at line 100 of file ksavefile.cpp. References KTempFile::close(), and KTempFile::unlink(). Referenced by close(), and KConfigINIBackEnd::writeConfigFile(). |
|
Closes the file and makes the changes definitive. Returns 'true' is successful, or 'false' if an error has occurred. See status() for details about errors.
Definition at line 107 of file ksavefile.cpp. References abort(), KTempFile::close(), KTempFile::handle(), KTempFile::name(), KTempFile::setError(), KTempFile::sync(), and KTempFile::unlink(). Referenced by KPalette::save(), KConfigINIBackEnd::writeConfigFile(), and ~KSaveFile(). |
|
Static method to create a backup file before saving. You can use this method even if you don't use KSaveFile.
Definition at line 145 of file ksavefile.cpp. References backupFile(). Referenced by backupFile(). |
The documentation for this class was generated from the following files: