Belle II Software development
|
Utility functions related to filename validation and filesystem access. More...
#include <FileSystem.h>
Classes | |
class | Lock |
Helper class for locking a file. More... | |
class | TemporaryFile |
Helper file to create a temporary file and ensure deletion if object goes out of scope. More... | |
Static Public Member Functions | |
static std::string | findFile (const std::string &path, bool silent=false) |
Search for given file or directory in local or central release directory, and return absolute path if found. | |
static std::string | findFile (const std::string &path, const std::string &dataType, bool silent=false) |
Search for given file or directory in the directory given by the environment variable BELLE2_<DATATYPE>_DATA_DIR or local/central release directory and return absolute path if found. | |
static bool | fileExists (const std::string &filename) |
Check if the file with given filename exists. | |
static bool | fileDirExists (const std::string &filename) |
Check if the dir containing the filename exists. | |
static bool | isFile (const std::string &filename) |
Check if filename points to an existing file. | |
static bool | isDir (const std::string &filename) |
Check if filename points to an existing directory. | |
static bool | isSymLink (const std::string &filename) |
Check if filename points to an existing symbolic link. | |
static std::string | calculateMD5 (const std::string &filename) |
Calculate the MD5 checksum of a given file. | |
static std::string | calculateAdler32 (const std::string &filename) |
Calculate the Adler-32 checksum of a given file. | |
static bool | loadLibrary (std::string library, bool fullname=true) |
Load a shared library. | |
Private Member Functions | |
FileSystem ()=delete | |
no instances. | |
Static Private Member Functions | |
static std::string | findFile (const std::string &path, const std::vector< std::string > &dirs, bool silent) |
Search for given file or directory in list of directories or working directory. | |
Utility functions related to filename validation and filesystem access.
Definition at line 20 of file FileSystem.h.
|
static |
Calculate the Adler-32 checksum of a given file.
Definition at line 86 of file FileSystem.cc.
|
static |
Calculate the MD5 checksum of a given file.
Definition at line 78 of file FileSystem.cc.
|
static |
Check if the dir containing the filename exists.
Definition at line 38 of file FileSystem.cc.
|
static |
Check if the file with given filename exists.
Definition at line 32 of file FileSystem.cc.
|
static |
Search for given file or directory in local or central release directory, and return absolute path if found.
If the file isn't found in either of these, absolute paths and paths relative to the current working directory are also accepted.
It is recommended to replace any relative paths you have with the return value of this function during initialization.
path | path to file/directory, assuming it's installed locally (e.g. /data/geometry/Belle2.xml). Leading slash is not strictly required. |
silent | If true, no error message is printed when file could not be found. |
Definition at line 151 of file FileSystem.cc.
|
static |
Search for given file or directory in the directory given by the environment variable BELLE2_<DATATYPE>_DATA_DIR or local/central release directory and return absolute path if found.
If the file isn't found in either of these, absolute paths and paths relative to the current working directory are also accepted.
It is recommended to replace any relative paths you have with the return value of this function during initialization.
path | path to file/directory, assuming it's installed locally (e.g. /data/geometry/Belle2.xml). Leading slash is not strictly required. |
dataType | type of data, like "examples" or "validation". |
silent | If true, no error message is printed when file could not be found. |
Definition at line 163 of file FileSystem.cc.
|
staticprivate |
Search for given file or directory in list of directories or working directory.
Definition at line 115 of file FileSystem.cc.
|
static |
Check if filename points to an existing directory.
Definition at line 51 of file FileSystem.cc.
|
static |
Check if filename points to an existing file.
Definition at line 45 of file FileSystem.cc.
|
static |
Check if filename points to an existing symbolic link.
Definition at line 57 of file FileSystem.cc.
|
static |
Load a shared library.
Symbols are resolved only when used, slightly reducing loading time (RTLD_LAZY, see dlopen(3))
library | Name of the library |
fullname | If false, the Library name is interpreted as short name like given to the compiler with -l. It will be expanded to lib<library>.so |
Definition at line 63 of file FileSystem.cc.