CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
Public Member Functions | Protected Attributes | List of all members
ctkScopedCurrentDir Class Reference

Use this class to change the current application directory in a given scope and automatically restore it. More...

#include <Libs/Core/ctkScopedCurrentDir.h>

Public Member Functions

 ctkScopedCurrentDir (const QString &path)
 
QString currentPath () const
 
QString savedCurrentPath () const
 Return saved current path. More...
 
virtual ~ctkScopedCurrentDir ()
 

Protected Attributes

QScopedPointer< ctkScopedCurrentDirPrivate > d_ptr
 

Detailed Description

Use this class to change the current application directory in a given scope and automatically restore it.

This is particulary useful in case a plugin and its dependent libraries should be loaded from a known directory. Indeed, changing the application PATH, LD_LIBRARY_PATH or DYLD_LIBRARY_PATH within the current process won't have the desired effect. The loader checks for these variables only once when the process starts.

See also
http://stackoverflow.com/questions/856116/changing-ld-library-path-at-runtime-for-ctypes
http://stackoverflow.com/questions/1178094/change-current-process-environment

Definition at line 45 of file ctkScopedCurrentDir.h.

Constructor & Destructor Documentation

◆ ctkScopedCurrentDir()

ctkScopedCurrentDir::ctkScopedCurrentDir ( const QString &  path)
explicit

◆ ~ctkScopedCurrentDir()

virtual ctkScopedCurrentDir::~ctkScopedCurrentDir ( )
virtual

Member Function Documentation

◆ currentPath()

QString ctkScopedCurrentDir::currentPath ( ) const

Return the current application path

See also
QDir::currentPath

◆ savedCurrentPath()

QString ctkScopedCurrentDir::savedCurrentPath ( ) const

Return saved current path.

Member Data Documentation

◆ d_ptr

QScopedPointer<ctkScopedCurrentDirPrivate> ctkScopedCurrentDir::d_ptr
protected

Definition at line 59 of file ctkScopedCurrentDir.h.


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