SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
|
Obtain filesystem paths relevant to SMTK. More...
#include <Paths.h>
Public Member Functions | |
Paths () | |
Construct a path-discovery instance without providing the current executable's path. | |
Paths (const std::string &argv0) | |
Construct a path-discovery instance, providing the current executable's path for use as a starting point. | |
std::string | executableDirectory () |
Return the best guess at the directory containing the current process's executable. | |
std::string | toplevelDirectory () |
Return the best guess at the top-level SMTK install directory. | |
std::string | bundleDirectory () |
Return the best guess at the bundle directory. More... | |
std::vector< std::string > | workerSearchPaths (bool pruneInvalid=true) |
Return the best guess at the top-level SMTK install directory. | |
std::string | toplevelDirectoryConfigured () |
Return the top-level SMTK install directory configured when the package was built. | |
void | forceUpdate () |
Force the path cache to be rebuilt. More... | |
Static Public Member Functions | |
static std::string | currentDirectory () |
Return the current working directory. | |
static bool | directoryExists (const std::string &path) |
Is the given path a directory? | |
static bool | createDirectory (const std::string &path) |
Create a directory (and all its containing directories as needed). More... | |
static std::vector< std::string > | pruneInvalidDirectories (const std::vector< std::string > &src) |
Filter the input src, returning the subset of paths that are existing directories. | |
static std::string | pathToLibraryContainingFunction (void(*func)()) |
Return the directory containing the library that describes func. | |
static std::string | pathToThisLibrary () |
Return the directory containing this library. | |
static bool | fileExists (const std::string &path) |
Is the given path a file? | |
static bool | isRelative (const std::string &path) |
Is the path relative (i.e., not absolute)? More... | |
static bool | areEquivalent (const std::string &pathA, const std::string &pathB) |
Return true when pathA and pathB resolve to the same location. More... | |
static std::string | canonical (const std::string &path, const std::string &base={}) |
Return the canonical version of a path, which must exist on disk. More... | |
static std::string | directory (const std::string &path) |
Return the directory containing a file, given a path to the file. | |
static std::string | filename (const std::string &path) |
Return the file name, given a path to the file. | |
static std::string | stem (const std::string &path) |
Return the file name without extension, given a path to the file. | |
static std::string | extension (const std::string &path) |
Return the file extension, given a path to the file. | |
static std::string | replaceExtension (const std::string &path, const std::string &newExtension) |
Return the path with file extension replaced. | |
static std::string | replaceFilename (const std::string &path, const std::string &newFilename) |
Return the path with filename replaced. | |
static std::string | tempDirectory () |
static std::string | uniquePath () |
Protected Member Functions | |
bool | update () |
Update cached search paths and top-level install directories, if needed. | |
Static Protected Attributes | |
static std::string | s_executable |
The path to the current process's executable on the filesystem. | |
static std::string | s_toplevelDirCfg |
The toplevel install-directory determined at configure-time; sometimes used as a hint. | |
static int | s_lastSet = 0 |
The last time the program path or other global setting was changed. | |
static int | s_lastGen = -1 |
The last time the search-path cache was generated from global settings. | |
static std::string | s_executableDir |
The directory containing the executable. | |
static std::string | s_toplevelDir |
The top-level install directory for SMTK. | |
static std::string | s_bundleDir |
The bundle directory for SMTK on Mac OS X. | |
static std::vector< std::string > | s_workerSearchPaths |
The ordered list of directories to search for Remus worker files. | |
Friends | |
class | PathsHelperUnix |
class | PathsHelperMacOSX |
class | PathsHelperWindows |
Obtain filesystem paths relevant to SMTK.
This class encapsulates platform specific information for obtaining search paths needed by SMTK.
As much as possible, it uses run-time information instead of configure- or compile-time information to discover where things are located relative to the current executable.
|
static |
Return true when pathA and pathB resolve to the same location.
Note: both input paths must exist on the filesystem, otherwise this function will emit an error message and return false.
std::string smtk::common::Paths::bundleDirectory | ( | ) |
Return the best guess at the bundle directory.
This should be empty on all platforms except Mac OS X and iOS. Otherwise, it should point to the top of the main bundle (i.e., [NSBundle mainBundle]).
|
static |
Return the canonical version of a path, which must exist on disk.
The canonical path is an unambiguous and absolute path with (1) no single- or double-dots and (2) no symbolic links. On error, an empty string is returned and a log message is generated.
|
static |
Create a directory (and all its containing directories as needed).
Returns true if the directory pre-existed or was successfully created and false if it could not be created (e.g., due to permissions, a full filesystem, or a plain file whose name matches a directory in the path).
void smtk::common::Paths::forceUpdate | ( | ) |
Force the path cache to be rebuilt.
This is useful if you believe an environment variable has changed or some other undetectable event has occurred.
|
static |
Is the path relative (i.e., not absolute)?
Note that on Windows a path requires a drive letter to be absolute, so more paths than you may expect will be reported as relative.