org.kde.koala

Class KTempDir

public class KTempDir extends Object implements QtSupport

The KTempDir class creates a unique directory for temporary use. This is especially useful if you need to create a directory in a world writable directory like /tmp without being vulnerable to so called symlink attacks. KDE applications, however, shouldn't create files or directories in /tmp in the first place but use the "tmp" resource instead. The standard KTempDir constructor will do that by default. To create a temporary directory that starts with a certain name in the "tmp" resource, one should use: KTempDir(locateLocal("tmp", prefix)); KTempFile does not create any missing directories, but locateLocal() does. See also KStandardDirs

Author: Joseph Wenninger

UNKNOWN: The KTempDir class creates a unique directory for temporary use.

Constructor Summary
protected KTempDir(Class dummy)
KTempDir(String directoryPrefix, int mode)
Creates a temporary directory with the name: \p \\ The default
directoryPrefix
is "$KDEHOME/tmp-$HOST/appname"
KTempDir(String directoryPrefix)
KTempDir()
Method Summary
protected booleancreate(String directoryPrefix, int mode)
Creates a "random" directory with specified mode
voiddispose()
Delete the wrapped C++ instance ahead of finalize()
booleanexisting()
protected voidfinalize()
Deletes the wrapped C++ instance
booleanisDisposed()
Has the wrapped C++ instance been deleted?
Stringname()
Returns the full path and name of the directory, including a trailing '/'.
QDirqDir()
Returns the QDir of the temporary directory.
voidsetAutoDelete(boolean autoDelete)
Turn automatic deletion on or off.
protected voidsetError(int error)
Sets the errno value
intstatus()
Returns the status of the directory creation based on errno. (see errno.h) 0 means OK.
voidunlink()
Deletes the directory recursively

Constructor Detail

KTempDir

protected KTempDir(Class dummy)

KTempDir

public KTempDir(String directoryPrefix, int mode)
Creates a temporary directory with the name: \p \\ The default
directoryPrefix
is "$KDEHOME/tmp-$HOST/appname"

Parameters: directoryPrefix the prefix of the file name, or null for the default value mode the file permissions, almost always in octal. The first digit selects permissions for the user who owns the file: read (4), write (2), and execute (1); the second selects permissions for other users in the file's group, with the same values; and the fourth for other users not in the file's group, with the same values.

UNKNOWN: Creates a temporary directory with the name: \p \\

KTempDir

public KTempDir(String directoryPrefix)

KTempDir

public KTempDir()

Method Detail

create

protected boolean create(String directoryPrefix, int mode)
Creates a "random" directory with specified mode

Parameters: directoryPrefix to use when creating temp directory (the rest is generated randomly) mode directory permissions

Returns: bool true upon sucess

UNKNOWN: Creates a "random" directory with specified mode

dispose

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

existing

public boolean existing()

Returns: true if a temporary directory has successfully been created and not been unlinked yet

UNKNOWN:

finalize

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

isDisposed

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

name

public String name()
Returns the full path and name of the directory, including a trailing '/'.

Returns: The name of the directory, or null if creating the directory has failed or the directory has been unlinked

UNKNOWN: Returns the full path and name of the directory, including a trailing '/'.

qDir

public QDir qDir()
Returns the QDir of the temporary directory.

Returns: QDir directory information of the directory or 0 if their is no managed directory The caller has to free the pointer open for writing to the

UNKNOWN: Returns the QDir of the temporary directory.

setAutoDelete

public void setAutoDelete(boolean autoDelete)
Turn automatic deletion on or off. Automatic deletion is off by default.

Parameters: autoDelete true to turn automatic deletion on

UNKNOWN: Turn automatic deletion on or off.

setError

protected void setError(int error)
Sets the errno value

Parameters: error the value to set the status to.

UNKNOWN: Sets the errno value

status

public int status()
Returns the status of the directory creation based on errno. (see errno.h) 0 means OK. You should check the status after object creation to check whether a directory could be created in the first place.

Returns: the errno status, 0 means ok

UNKNOWN: Returns the status of the directory creation based on errno.

unlink

public void unlink()
Deletes the directory recursively

UNKNOWN: Deletes the directory recursively