Workspace 6.21.5
Public Member Functions | List of all members
TemporaryDirectory Class Reference

An application-level temporary directory, similar to QTemporaryFile. More...

#include <Workspace/Application/System/temporarydirectory.h>

Inheritance diagram for TemporaryDirectory:
[legend]

Public Member Functions

 TemporaryDirectory (const QString &prefix)
 
 TemporaryDirectory (const TemporaryDirectory &tmpDir)
 
 ~TemporaryDirectory ()
 
QDir getDir () const
 
QString getFilePath (const QString &fileName) const
 
QString getPath () const
 
QString getPrefix () const
 
bool isValid () const
 
TemporaryDirectoryoperator= (const TemporaryDirectory &tmpDir)
 

Detailed Description

This class creates an application-level temporary directory. It uses reference counting internally to ensure that when all TemporaryDirectory objects for a given prefix are deleted, the temporary directory is also deleted along with all its contents.

This class is thread-safe.

Constructor & Destructor Documentation

◆ TemporaryDirectory() [1/2]

TemporaryDirectory ( const QString &  prefix)
Parameters
prefixThe prefix to use for the temporary directory. The final name of the temporary directory will be this prefix with some characters including the process id appended to it.

The permissions of the temporary directory will be set to allow only the current user to read from or write to it.

◆ TemporaryDirectory() [2/2]

Parameters
tmpDirThe object to copy.

◆ ~TemporaryDirectory()

When no more TemporaryDirectory objects for the specified prefix exist, the destructor attempts to delete the temporary directory, including all of its contents.

Member Function Documentation

◆ getDir()

QDir getDir ( ) const
Returns
The temporary directory this object represents.

◆ getFilePath()

QString getFilePath ( const QString &  fileName) const
Parameters
fileNameThe name of a file within the temporary directory. The file does not have to exist.

This function is equivalent to calling getDir().filePath(fileName).

Returns
The path to the specified file within the temporary directory.

◆ getPath()

QString getPath ( ) const
Returns
The path to the temporary directory. This is equivalent to calling getDir().path()

◆ getPrefix()

QString getPrefix ( ) const
Returns
The prefix that was passed to the constructor.

◆ isValid()

bool isValid ( ) const
Returns
True if the temporary directory exists (ie it was created successfully by the constructor).

This function is equivalent to calling getDir().exists().

◆ operator=()

TemporaryDirectory & operator= ( const TemporaryDirectory tmpDir)
Parameters
tmpDirThe object to assign from.