.TH "KSaveFile" 3 "28 Jan 2004" "kdecore Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KSaveFile \- The KSaveFile class has been made to write out changes to an existing file atomically.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <ksavefile.h>\fP
.PP
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "\fBKSaveFile\fP (const  \fBQString\fP &filename, int mode=0666)"
.br
.RI "\fICreates a new KSaveFile with the given file name. \fP"
.ti -1c
.RI "\fB~KSaveFile\fP ()"
.br
.RI "\fIThe destructor closes the file. \fP"
.ti -1c
.RI "int \fBstatus\fP () const "
.br
.RI "\fIReturns the status of the file based on errno. \fP"
.ti -1c
.RI "\fBQString\fP \fBname\fP () const "
.br
.RI "\fIThe name of the file as passed to the constructor. \fP"
.ti -1c
.RI "int \fBhandle\fP () const "
.br
.RI "\fIAn integer file descriptor open for writing to the file. \fP"
.ti -1c
.RI "FILE * \fBfstream\fP ()"
.br
.RI "\fIA FILE* stream open for writing to the file. \fP"
.ti -1c
.RI "\fBQFile\fP * \fBfile\fP ()"
.br
.RI "\fIA QFile* open for writing to the file. \fP"
.ti -1c
.RI "\fBQTextStream\fP * \fBtextStream\fP ()"
.br
.RI "\fIA QTextStream* open for writing to the file. \fP"
.ti -1c
.RI "\fBQDataStream\fP * \fBdataStream\fP ()"
.br
.RI "\fIA QDataStream* open for writing to the file. \fP"
.ti -1c
.RI "void \fBabort\fP ()"
.br
.RI "\fIAborts the write operation and removes any intermediate files This implies a close. \fP"
.ti -1c
.RI "bool \fBclose\fP ()"
.br
.RI "\fICloses the file and makes the changes definitive. \fP"
.in -1c
.SH "Detailed Description"
.PP 
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.
.PP
b) Some error occured, no changes have been written whatsoever and the old file is still in place. 
.PP
Definition at line 41 of file ksavefile.h.
.SH "Constructor & Destructor Documentation"
.PP 
.SS "KSaveFile::KSaveFile (const \fBQString\fP & filename, int mode = 0666)"
.PP
Creates a new KSaveFile with the given file name. \fBParameters:\fP
.RS 4
\fIfilename\fP the path of the file 
.br
\fImode\fP the mode of the file (see chmod(1)) 
.RE
.PP
Definition at line 41 of file ksavefile.cpp.
.PP
References KTempFile::create(), QString::fromLatin1(), and KTempFile::setError().
.SS "KSaveFile::~\fBKSaveFile\fP ()"
.PP
The destructor closes the file. Definition at line 60 of file ksavefile.cpp.
.PP
References close().
.SH "Member Function Documentation"
.PP 
.SS "int KSaveFile::status () const\fC [inline]\fP"
.PP
Returns the status of the file based on errno. (see errno.h) 0 means OK.
.PP
You should check the status after object creation to check whether a file could be created in the first place.
.PP
You may check the status after closing the file to verify that the file has indeed been written correctly. 
.PP
\fBReturns:\fP
.RS 4
the errno status, 0 means ok 
.RE
.PP
Definition at line 67 of file ksavefile.h.
.PP
References KTempFile::status().
.PP
Referenced by KPalette::save(), and KConfigINIBackEnd::writeConfigFile().
.SS "\fBQString\fP KSaveFile::name () const"
.PP
The name of the file as passed to the constructor. \fBReturns:\fP
.RS 4
The name of the file, or QString::null if opening the file has failed 
.RE
.PP
Definition at line 66 of file ksavefile.cpp.
.SS "int KSaveFile::handle () const\fC [inline]\fP"
.PP
An integer file descriptor open for writing to the file. \fBReturns:\fP
.RS 4
The file descriptor, or a negative number if opening the temporary file failed 
.RE
.PP
Definition at line 82 of file ksavefile.h.
.PP
References KTempFile::handle().
.PP
Referenced by KConfigINIBackEnd::writeConfigFile().
.SS "FILE* KSaveFile::fstream ()\fC [inline]\fP"
.PP
A FILE* stream open for writing to the file. \fBReturns:\fP
.RS 4
FILE* stream open for writing to the file, or 0 if opening the temporary file failed 
.RE
.PP
Definition at line 90 of file ksavefile.h.
.PP
References KTempFile::fstream().
.PP
Referenced by KConfigINIBackEnd::writeConfigFile().
.SS "\fBQFile\fP* KSaveFile::file ()\fC [inline]\fP"
.PP
A QFile* open for writing to the file. \fBReturns:\fP
.RS 4
A \fBQFile\fP open for writing to the file, or 0 if opening the temporary file failed. 
.RE
.PP
Definition at line 98 of file ksavefile.h.
.PP
References KTempFile::file().
.SS "\fBQTextStream\fP* KSaveFile::textStream ()\fC [inline]\fP"
.PP
A QTextStream* open for writing to the file. \fBReturns:\fP
.RS 4
A \fBQTextStream\fP that is open for writing to the file, or 0 if opening the temporary file failed 
.RE
.PP
Definition at line 106 of file ksavefile.h.
.PP
References KTempFile::textStream().
.PP
Referenced by KPalette::save().
.SS "\fBQDataStream\fP* KSaveFile::dataStream ()\fC [inline]\fP"
.PP
A QDataStream* open for writing to the file. \fBReturns:\fP
.RS 4
A \fBQDataStream\fP that is open for writing to the file, or 0 if opening the file failed 
.RE
.PP
Definition at line 114 of file ksavefile.h.
.PP
References KTempFile::dataStream().
.SS "void KSaveFile::abort ()"
.PP
Aborts the write operation and removes any intermediate files This implies a close. Definition at line 72 of file ksavefile.cpp.
.PP
References KTempFile::close(), and KTempFile::unlink().
.SS "bool KSaveFile::close ()"
.PP
Closes the file and makes the changes definitive. Returns 'true' is successful, or 'false' if an error has occured. See \fBstatus()\fP for details about errors. 
.PP
\fBReturns:\fP
.RS 4
true if successful, or false if an error has occured. 
.RE
.PP
Definition at line 79 of file ksavefile.cpp.
.PP
References KTempFile::close(), QString::isEmpty(), KTempFile::name(), QDir::rename(), KTempFile::setError(), and KTempFile::unlink().
.PP
Referenced by KPalette::save(), KConfigINIBackEnd::writeConfigFile(), and ~KSaveFile().

.SH "Author"
.PP 
Generated automatically by Doxygen for kdecore Library from the source code.
