Loading...
Searching...
No Matches
BALL::Path Class Reference
Foundation Classes » Operating system support

`#include <BALL/SYSTEM/path.h>`

## Constructors and Destructors

static String | path_
static bool | path_array_valid_
static bool | environment_checked_
static std::vector< String > | path_array_
static bool | initialized_
| Path ()
String | getDataPath ()
void | setDataPath (const String &path)
void | addDataPath (const String &path)
String | getDefaultDataPath ()
String | find (const String &name)
String | findStrict (const String &name)
void | reset ()
| Reset the path variable to its default state (as it was a the start of the application).
void | buildPathArray_ ()

## Detailed Description

Data path management class. This class is intended to provide a unique interface to directories where the data files needed by BALL reside.

  Path is a singleton, so there is only one unique application-wide instance of and changes to this will be seen by all classes using path.

Definition at line 39 of file path.h.

## Constructor & Destructor Documentation

## Path()

BALL::Path::Path | ( |  | ) |

Default constructor

## Member Function Documentation

## addDataPath()

void BALL::Path::addDataPath | ( | const String & | path | ) |

Add a single path to the list of paths.

Parameters

  path | the path to be added to the path list

## buildPathArray_()

void BALL::Path::buildPathArray_ | ( |  | ) |

protected

## find()

String BALL::Path::find | ( | const String & | name | ) |

Returns the full path to a file residing in one of the data directories. If a file that matches the name is not found, an empty string is returned. Directories are searched in the order of occurence in the data path. If name contains relative path information but no file matching this path could be found, another search is performed as a second step taking in account only the basename of the file.

  E.g.:

  Specifying data/test.dat will search for data/test.dat in each data directory first. If this search doesn't yield a match, find will search for a file named test.dat in each of the directories.

  If this behaviour is not desired, try findStrict instead.

## findStrict()

String BALL::Path::findStrict | ( | const String & | name | ) |

Returns the full path to a file residing in one of the data directories.

See also
  find

## getDataPath()

String BALL::Path::getDataPath | ( |  | ) |

Return a list of paths to the BALL data directories. This directory is set to a default value at compile time of the library. It may be overridden at runtime by setting the environment variable "BALL_DATA" to the desired value. This value is then prepended to the list of directories. Directories are separated by linefeeds and returned as a single string. To locate files in these directories, find will search the directories in the specified order.

The default path may be accessed using getDefaultDataPath . The path may also be modified at runtime by calling setDataPath .

The path contains a newline ("\n") separated list of paths that are searched in the order of occurence.

## getDefaultDataPath()

String BALL::Path::getDefaultDataPath | ( |  | ) |

Returns the default data path compiled into the library. This method ignores possible contents of the environment variable "BALL\_DATA".

## reset()

void BALL::Path::reset | ( |  | ) |

Reset the path variable to its default state (as it was a the start of the application).

## setDataPath()

void BALL::Path::setDataPath | ( | const String & | path | ) |

Modify the data path. This method accepts a newline separated list of paths to specify data paths.

## Member Data Documentation

## environment_checked_

bool BALL::Path::environment_checked_

static protected

Definition at line 116 of file path.h.

## initialized_

bool BALL::Path::initialized_

static protected

Definition at line 118 of file path.h.

## path_

String BALL::Path::path_

static protected

Definition at line 114 of file path.h.

## path_array_

std::vector<String> BALL::Path::path_array_

static protected

Definition at line 117 of file path.h.

## path_array_valid_

bool BALL::Path::path_array_valid_

static protected

Definition at line 115 of file path.h.