.TH "KTempDir" kde3 "11 Jun 2005" "Version Version 3.4.1" "kdecore Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KTempDir \- The KTempDir class creates a unique directory for temporary use.  

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

.in +1c
.ti -1c
.RI "\fBKTempDir\fP (\fBQString\fP directoryPrefix=QString::null, int mode=0700)"
.br
.ti -1c
.RI "\fB~KTempDir\fP ()"
.br
.ti -1c
.RI "void \fBsetAutoDelete\fP (bool autoDelete)"
.br
.ti -1c
.RI "int \fBstatus\fP () const "
.br
.ti -1c
.RI "\fBQString\fP \fBname\fP () const "
.br
.ti -1c
.RI "\fBQDir\fP * \fBqDir\fP ()"
.br
.ti -1c
.RI "void \fBunlink\fP ()"
.br
.ti -1c
.RI "bool \fBexisting\fP () const "
.br
.in -1c
.SS "Protected Member Functions"

.in +1c
.ti -1c
.RI "bool \fBcreate\fP (const \fBQString\fP &directoryPrefix, int mode)"
.br
.ti -1c
.RI "void \fBsetError\fP (int error)"
.br
.in -1c
.SH "Detailed Description"
.PP 
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.
.PP
\fBKDE\fP 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.
.PP
To create a temporary directory that starts with a certain name in the 'tmp' resource, one should use: KTempDir(locateLocal('tmp', prefix));
.PP
\fBKTempFile\fP does not create any missing directories, but locateLocal() does.
.PP
See also \fBKStandardDirs\fP
.PP
\fBSince:\fP
.RS 4
3.2 
.RE
.PP
\fBAuthor:\fP
.RS 4
Joseph Wenninger <jowenn@kde.org> 
.RE
.PP

.PP
Definition at line 53 of file ktempdir.h.
.SH "Constructor & Destructor Documentation"
.PP 
.SS "KTempDir::KTempDir (\fBQString\fP directoryPrefix = \fCQString::null\fP, int mode = \fC0700\fP)"
.PP
Creates a temporary directory with the name: \fC<directoryPrefix><six\fP letters>. 
.PP
The default \fCdirectoryPrefix\fP is '$KDEHOME/tmp-$HOST/appname' 
.PP
\fBParameters:\fP
.RS 4
\fIdirectoryPrefix\fP the prefix of the file name, or QString::null for the default value 
.br
\fImode\fP 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. 
.RE
.PP

.PP
Definition at line 57 of file ktempdir.cpp.
.PP
References create(), and QString::isEmpty().
.SS "KTempDir::~\fBKTempDir\fP ()"
.PP
The destructor deletes the directory and it's contents if autoDelete is enabled. 
.PP
Definition at line 104 of file ktempdir.cpp.
.PP
References unlink().
.SH "Member Function Documentation"
.PP 
.SS "void KTempDir::setAutoDelete (bool autoDelete)\fC [inline]\fP"
.PP
Turn automatic deletion on or off. 
.PP
Automatic deletion is off by default. 
.PP
\fBParameters:\fP
.RS 4
\fIautoDelete\fP true to turn automatic deletion on 
.RE
.PP

.PP
Definition at line 85 of file ktempdir.h.
.SS "int KTempDir::status () const"
.PP
Returns the status of the directory creation based on errno. 
.PP
(see errno.h) 0 means OK.
.PP
You should check the status after object creation to check whether a directory could be created in the first place.
.PP
\fBReturns:\fP
.RS 4
the errno status, 0 means ok 
.RE
.PP

.PP
Definition at line 111 of file ktempdir.cpp.
.SS "\fBQString\fP KTempDir::name () const"
.PP
Returns the full path and name of the directory, including a trailing '/'. 
.PP
\fBReturns:\fP
.RS 4
The name of the directory, or QString::null if creating the directory has failed or the directory has been unlinked 
.RE
.PP

.PP
Definition at line 117 of file ktempdir.cpp.
.SS "\fBQDir\fP * KTempDir::qDir ()"
.PP
Returns the QDir* of the temporary directory. 
.PP
\fBReturns:\fP
.RS 4
\fBQDir\fP 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 
.RE
.PP

.PP
Definition at line 129 of file ktempdir.cpp.
.SS "void KTempDir::unlink ()"
.PP
Deletes the directory recursively. 
.PP
Definition at line 136 of file ktempdir.cpp.
.PP
References QFile::encodeName(), and KProcess::quote().
.PP
Referenced by ~KTempDir().
.SS "bool KTempDir::existing () const"
.PP
\fBReturns:\fP
.RS 4
true if a temporary directory has successfully been created and not been unlinked yet 
.RE
.PP

.PP
Definition at line 123 of file ktempdir.cpp.
.SS "bool KTempDir::create (const \fBQString\fP & directoryPrefix, int mode)\fC [protected]\fP"
.PP
Creates a 'random' directory with specified mode. 
.PP
\fBParameters:\fP
.RS 4
\fIdirectoryPrefix\fP to use when creating temp directory (the rest is generated randomly) 
.br
\fImode\fP directory permissions 
.RE
.PP
\fBReturns:\fP
.RS 4
bool true upon sucess 
.RE
.PP

.PP
Definition at line 70 of file ktempdir.cpp.
.PP
References QFile::decodeName(), QFile::encodeName(), endl(), and KApplication::random().
.PP
Referenced by KTempDir().
.SS "void KTempDir::setError (int error)\fC [inline, protected]\fP"
.PP
Sets the errno value. 
.PP
\fBParameters:\fP
.RS 4
\fIerror\fP the value to set the status to. 
.RE
.PP

.PP
Definition at line 138 of file ktempdir.h.

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