Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::StandardFileLocations Class Reference

Provides methods to look for configuration and option files in standard locations. More...

#include <mitkStandardFileLocations.h>

Inheritance diagram for mitk::StandardFileLocations:
Collaboration diagram for mitk::StandardFileLocations:

Public Types

typedef StandardFileLocations Self
 
typedef itk::Command Superclass
 
typedef itk::SmartPointer< Self > Pointer
 

Public Member Functions

void AddDirectoryForSearch (const char *dir, bool insertInFrontOfSearchList=true)
 Add a directory to the search queue. More...
 
void RemoveDirectoryForSearch (const char *dir)
 Remove a directory from the search queue. More...
 
std::string FindFile (const char *filename, const char *pathInSourceDir=nullptr)
 Look for a file in several standard locations. More...
 
std::string GetOptionDirectory ()
 Return the directory for option files. More...
 

Static Public Member Functions

static StandardFileLocations * GetInstance ()
 Get the singleton instance of StandardFileLocations. More...
 

Protected Types

typedef std::vector< std::string > FileSearchVectorType
 

Protected Member Functions

Pointer Clone () const
 
 StandardFileLocations ()
 
 ~StandardFileLocations () override
 
std::string SearchDirectoriesForFile (const char *filename)
 Search all directories in the search queue for the given file. More...
 

Static Protected Member Functions

static Pointer New ()
 

Protected Attributes

FileSearchVectorType m_SearchDirectories
 

Detailed Description

Provides methods to look for configuration and option files in standard locations.

Call mitk::StandardFileLocations::FindFile(filename) to look for configuration files. Call mitk::StandardFileLocations::GetOptionDirectory() to look for/save option files.

Definition at line 30 of file mitkStandardFileLocations.h.

Member Typedef Documentation

◆ FileSearchVectorType

typedef std::vector<std::string> mitk::StandardFileLocations::FileSearchVectorType
protected

Definition at line 108 of file mitkStandardFileLocations.h.

◆ Pointer

◆ Self

◆ Superclass

Definition at line 34 of file mitkStandardFileLocations.h.

Constructor & Destructor Documentation

◆ StandardFileLocations()

mitk::StandardFileLocations::StandardFileLocations ( )
protected

◆ ~StandardFileLocations()

mitk::StandardFileLocations::~StandardFileLocations ( )
overrideprotected

Member Function Documentation

◆ AddDirectoryForSearch()

void mitk::StandardFileLocations::AddDirectoryForSearch ( const char *  dir,
bool  insertInFrontOfSearchList = true 
)

Add a directory to the search queue.

Use this function in combination with FindFile(). After adding some directories, they will also be searched for the requested file.

Parameters
[in]dirdirectory you want to be searched in.
[in]insertInFrontOfSearchListwhether this search request shall be processed first.

◆ Clone()

Pointer mitk::StandardFileLocations::Clone ( ) const
protected

◆ FindFile()

std::string mitk::StandardFileLocations::FindFile ( const char *  filename,
const char *  pathInSourceDir = nullptr 
)

Look for a file in several standard locations.

This method appends several standard locations to the end of the search queue (if they do not already exist) and then searches for the file within all directories contained in the search queue:

  1. Add the directory specified in the environment variable MITKCONF
  2. Add the .mitk directory in the home folder of the user
  3. Add the current working directory
  4. Add the (current working directory)/bin directory
  5. Add the directory specified in pathInSourceDir, relative to the source code directory root (determined at compile time)

Directories already added via AddDirectoryForSearch() before calling FindFile() are still searched first, because above mentioned standard locations are always appended at the end of the list.

Parameters
[in]filenamethe file you want to find, without any path.
[in]pathInSourceDirwhere in the source tree hierarchy the file would be.
Returns
The absolute path to the file including the filename, or an empty string if the file was not found.

◆ GetInstance()

static StandardFileLocations* mitk::StandardFileLocations::GetInstance ( )
static

Get the singleton instance of StandardFileLocations.

Returns
Pointer to the singleton instance.

◆ GetOptionDirectory()

std::string mitk::StandardFileLocations::GetOptionDirectory ( )

Return the directory for option files.

This method looks for the directory for option files in two ways:

  1. If there is an environment variable MITKOPTIONS, then use that directory.
  2. Use .mitk-subdirectory in the home directory of the user.

The directory will be created if it does not exist.

Returns
The absolute path to the directory for option files.

◆ New()

static Pointer mitk::StandardFileLocations::New ( )
staticprotected

◆ RemoveDirectoryForSearch()

void mitk::StandardFileLocations::RemoveDirectoryForSearch ( const char *  dir)

Remove a directory from the search queue.

Use this function in combination with FindFile().

Parameters
[in]dirdirectory to remove from the search queue.

◆ SearchDirectoriesForFile()

std::string mitk::StandardFileLocations::SearchDirectoriesForFile ( const char *  filename)
protected

Search all directories in the search queue for the given file.

Parameters
[in]filenamethe file to search for.
Returns
The absolute path to the file, or an empty string if not found.

Member Data Documentation

◆ m_SearchDirectories

FileSearchVectorType mitk::StandardFileLocations::m_SearchDirectories
protected

Definition at line 109 of file mitkStandardFileLocations.h.


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