A class that manages the creation and removal of a temporary directory tree to store data during the program run. More...

#include <TempDirectory.h>

Collaboration diagram for TempDirectory:
Collaboration graph

Public Member Functions

virtual ~TempDirectory ()
 
QString getContainingPath ()
 Return the path of the directory in which the temporary directory has been or will be created. More...
 
QString getPath ()
 Create the root temporary directory if necessary, and return its path. More...
 
QString getSubDirectoryPath (QString subdir)
 Create an immediate subdirectory of the root temporary directory of the given name, if it doesn't already exist, and return its path. More...
 
void cleanup ()
 Delete the temporary directory (before exiting). More...
 

Static Public Member Functions

static TempDirectorygetInstance ()
 

Protected Member Functions

 TempDirectory ()
 
QString createTempDirectoryIn (QString inDir)
 
void cleanupDirectory (QString tmpDir)
 
void cleanupAbandonedDirectories (QString svDir)
 

Protected Attributes

QString m_tmpdir
 
QMutex m_mutex
 

Static Protected Attributes

static TempDirectorym_instance = new TempDirectory
 

Detailed Description

A class that manages the creation and removal of a temporary directory tree to store data during the program run.

There is one root temporary directory for the program, created on demand and deleted when the program exits.

This class is thread safe.

Definition at line 33 of file TempDirectory.h.

Constructor & Destructor Documentation

TempDirectory::~TempDirectory ( )
virtual

Definition at line 45 of file TempDirectory.cpp.

References cleanup(), and SVDEBUG.

TempDirectory::TempDirectory ( )
protected

Definition at line 40 of file TempDirectory.cpp.

Member Function Documentation

QString TempDirectory::getContainingPath ( )

Return the path of the directory in which the temporary directory has been or will be created.

This directory is particular to this application, although not to this instance of it, and it will not be removed when the application exits. Persistent cache data or similar may be placed in this directory or other, non-temporary subdirectories of it.

If this directory does not exist, it will be created. Throw DirectoryCreationFailed if the directory cannot be created.

!! iffy

Definition at line 59 of file TempDirectory.cpp.

References cleanupAbandonedDirectories(), ResourceFinder::getUserResourcePrefix(), and m_mutex.

Referenced by CachedFile::getCacheDirectory(), and getPath().

QString TempDirectory::getPath ( )

Create the root temporary directory if necessary, and return its path.

This directory will be removed when the application exits.

Throw DirectoryCreationFailed if the directory cannot be created.

Definition at line 90 of file TempDirectory.cpp.

References createTempDirectoryIn(), getContainingPath(), and m_tmpdir.

Referenced by getSubDirectoryPath(), and StorageAdviser::recommend().

QString TempDirectory::getSubDirectoryPath ( QString  subdir)

Create an immediate subdirectory of the root temporary directory of the given name, if it doesn't already exist, and return its path.

This directory will be removed when the application exits.

Throw DirectoryCreationFailed if the directory cannot be created.

Definition at line 157 of file TempDirectory.cpp.

References getPath(), and m_mutex.

void TempDirectory::cleanup ( )

Delete the temporary directory (before exiting).

Definition at line 53 of file TempDirectory.cpp.

References cleanupDirectory().

Referenced by ~TempDirectory().

QString TempDirectory::createTempDirectoryIn ( QString  inDir)
protected

Definition at line 98 of file TempDirectory.cpp.

References m_tmpdir.

Referenced by getPath().

void TempDirectory::cleanupDirectory ( QString  tmpDir)
protected

Definition at line 180 of file TempDirectory.cpp.

References m_mutex, and m_tmpdir.

Referenced by cleanup(), and cleanupAbandonedDirectories().

void TempDirectory::cleanupAbandonedDirectories ( QString  svDir)
protected

Definition at line 239 of file TempDirectory.cpp.

References cleanupDirectory(), GetProcessStatus(), and ProcessNotRunning.

Referenced by getContainingPath().

Member Data Documentation

QString TempDirectory::m_tmpdir
protected

Definition at line 86 of file TempDirectory.h.

Referenced by cleanupDirectory(), createTempDirectoryIn(), and getPath().

QMutex TempDirectory::m_mutex
protected

Definition at line 87 of file TempDirectory.h.

Referenced by cleanupDirectory(), getContainingPath(), and getSubDirectoryPath().

TempDirectory * TempDirectory::m_instance = new TempDirectory
staticprotected

Definition at line 89 of file TempDirectory.h.

Referenced by getInstance().


The documentation for this class was generated from the following files: