org.kde.koala

Class KSaveFile

public class KSaveFile extends Object implements QtSupport

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.

UNKNOWN: The KSaveFile class has been made to write out changes to an existing file atomically.

Constructor Summary
protected KSaveFile(Class dummy)
KSaveFile(String filename, int mode)
Creates a new KSaveFile with the given file name.
KSaveFile(String filename)
Method Summary
voidabort()
Aborts the write operation and removes any intermediate files This implies a close.
static booleanbackupFile(String filename, String backupDir, String backupExtension)
Static method to create a backup file before saving.
static booleanbackupFile(String filename, String backupDir)
static booleanbackupFile(String filename)
booleanclose()
Closes the file and makes the changes definitive.
QDataStreamdataStream()
A QDataStream open for writing to the file.
voiddispose()
Delete the wrapped C++ instance ahead of finalize()
QFilefile()
A QFile open for writing to the file.
protected voidfinalize()
Deletes the wrapped C++ instance
inthandle()
An integer file descriptor open for writing to the file.
booleanisDisposed()
Has the wrapped C++ instance been deleted?
Stringname()
The name of the file as passed to the constructor.
intstatus()
Returns the status of the file based on errno. (see errno.h) 0 means OK.
QTextStreamtextStream()
A QTextStream open for writing to the file.

Constructor Detail

KSaveFile

protected KSaveFile(Class dummy)

KSaveFile

public KSaveFile(String filename, int mode)
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))

UNKNOWN: Creates a new KSaveFile with the given file name.

KSaveFile

public KSaveFile(String filename)

Method Detail

abort

public void abort()
Aborts the write operation and removes any intermediate files This implies a close.

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

backupFile

public static boolean backupFile(String filename, String backupDir, String backupExtension)
Static method to create a backup file before saving. You can use this method even if you don't use KSaveFile.

Parameters: filename the file to backup backupDir optional directory where to save the backup file in. If empty (the default), the backup will be in the same directory as filename. backupExtension the extension to append to filename, "~" by default.

UNKNOWN: Static method to create a backup file before saving.

backupFile

public static boolean backupFile(String filename, String backupDir)

backupFile

public static boolean backupFile(String filename)

close

public boolean close()
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.

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

UNKNOWN: Closes the file and makes the changes definitive.

dataStream

public QDataStream dataStream()
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

UNKNOWN: A QDataStream open for writing to the file.

dispose

public void dispose()
Delete the wrapped C++ instance ahead of finalize()

file

public QFile file()
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.

UNKNOWN: A QFile open for writing to the file.

finalize

protected void finalize()
Deletes the wrapped C++ instance

handle

public int handle()
An integer file descriptor open for writing to the file.

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

UNKNOWN: An integer file descriptor open for writing to the file.

isDisposed

public boolean isDisposed()
Has the wrapped C++ instance been deleted?

name

public String name()
The name of the file as passed to the constructor.

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

UNKNOWN: The name of the file as passed to the constructor.

status

public int status()
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

UNKNOWN: Returns the status of the file based on errno.

textStream

public QTextStream textStream()
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

UNKNOWN: A QTextStream open for writing to the file.