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

TemporaryDirectory subclass with additional support for Qt resource search paths. More...

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

Inheritance diagram for TemporaryDirectoryWithSearchPaths:
[legend]

Public Member Functions

 TemporaryDirectoryWithSearchPaths (const QString &prefix)
 
 ~TemporaryDirectoryWithSearchPaths ()
 
- Public Member Functions inherited from TemporaryDirectory
 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 extends TemporaryDirectory by also augmenting the Qt resource search path for the specified prefix. It will add the temporary directory to the front of the list of search paths for the specified prefix. The original list of search paths will be restored when the object is destroyed.

Note
The implementation currently assumes that TemporaryDirectoryWithSearchPaths objects will be destroyed in the reverse order in which they were created. If this condition is violated, nothing will crash, but the search paths will potentially not be restored back to their correct values as the objects are deleted. While this restriction is in place, this class is technically not thread-safe, but if you ensure that the last instance of one of these objects that gets destroyed for a given prefix is the first one created for that prefix, then the search path will at least end up back at what it started with (which is often all that is really required when using this class).

Constructor & Destructor Documentation

◆ TemporaryDirectoryWithSearchPaths()

TemporaryDirectoryWithSearchPaths ( 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 path to the temporary directory is prepended to the Qt resource search path for prefix as well.

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

◆ ~TemporaryDirectoryWithSearchPaths()