Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

KSaveFile Class Reference

#include <ksavefile.h>

List of all members.

Public Methods

 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 ()


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

KSaveFile::KSaveFile const QString &    filename,
int    mode = 0666
 

Creates a new KSaveFile with the given file name.

Parameters:
filename  the path of the file
mode  the mode of the file (see chmod(1))

KSaveFile::~KSaveFile  
 

The destructor closes the file.


Member Function Documentation

void KSaveFile::abort  
 

Aborts the write operation and removes any intermediate files This implies a close.

bool KSaveFile::close  
 

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.

Returns:
true if successful, or false if an error has occured.

QDataStream* KSaveFile::dataStream   [inline]
 

A QDataStream* open for writing to the file.

Returns:
A QDataStream that is open for writing to the file, or 0 if opening the file failed

Definition at line 114 of file ksavefile.h.

References KTempFile::dataStream().

QFile* KSaveFile::file   [inline]
 

A QFile* open for writing to the file.

Returns:
A QFile open for writing to the file, or 0 if opening the temporary file failed.

Definition at line 98 of file ksavefile.h.

References KTempFile::file().

FILE* KSaveFile::fstream   [inline]
 

A FILE* stream open for writing to the file.

Returns:
FILE* stream open for writing to the file, or 0 if opening the temporary file failed

Definition at line 90 of file ksavefile.h.

References KTempFile::fstream().

int KSaveFile::handle   const [inline]
 

An integer file descriptor open for writing to the file.

Returns:
The file descriptor, or a negative number if opening the temporary file failed

Definition at line 82 of file ksavefile.h.

References KTempFile::handle().

QString KSaveFile::name  
 

The name of the file as passed to the constructor.

Returns:
The name of the file, or QString::null if opening the file has failed

int KSaveFile::status   const [inline]
 

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.

Returns:
the errno status, 0 means ok

Definition at line 67 of file ksavefile.h.

References KTempFile::status().

QTextStream* KSaveFile::textStream   [inline]
 

A QTextStream* open for writing to the file.

Returns:
A QTextStream that is open for writing to the file, or 0 if opening the temporary file failed

Definition at line 106 of file ksavefile.h.

References KTempFile::textStream().


The documentation for this class was generated from the following file:
Generated on Wed Aug 13 23:30:22 2003 for kdelibs by doxygen1.2.18