#include <gromacs/utility/include/gromacs/utility/datafilefinder.h>
Searches data files from a set of paths.
gmx::DataFileFinder::DataFileFinder |
( |
| ) |
|
Constructs a default data file finder.
The constructed finder searches only in the directory specified by the global program context (see IProgramContext), and optionally in the current directory.
Does not throw.
Enumerates files in the data directories.
- Parameters
-
[in] | options | Idenfies files to be searched for. |
- Returns
- Information about each found file.
- Exceptions
-
std::bad_alloc | if out of memory. |
FileIOError | if no such file can be found, and options specifies that an exception should be thrown. |
Enumerates all files in the data directories that have the extension/suffix specified by the file name in options
. Unlike findFile() and openFile(), this only works on files that are in the actual data directories, not for any entry within subdirectories of those. See DataFileInfo for details on what is returned for each found file. Files from the same directory will be returned as a continuous block in the returned vector.
std::filesystem::path gmx::DataFileFinder::findFile |
( |
const DataFileOptions & |
options | ) |
const |
Finds a full path to a data file if found.
- Parameters
-
[in] | options | Identifies the file to be searched for. |
- Returns
- Full path to the data file, or an empty string if the file could not be found and exceptions were turned off.
- Exceptions
-
std::bad_alloc | if out of memory. |
FileIOError | if no such file can be found, and options specifies that an exception should be thrown. |
Searches for a data file in the search paths configured for the finder, as well as in the current directory if so required. Returns the full path to the first file found.
Opens a data file (if found) in an RAII-style FILE
handle.
- Parameters
-
[in] | options | Identifies the file to be searched for. |
- Returns
- The opened file handle, or
NULL
if the file could not be found and exceptions were turned off.
- Exceptions
-
std::bad_alloc | if out of memory. |
FileIOError | if
- no such file can be found, and
options specifies that an exception should be thrown, or
- there is an error opening the file (note that a file is skipped during the search if the user does not have rights to open the file at all).
|
See findFile() for more details.
void gmx::DataFileFinder::setSearchPathFromEnv |
( |
const char * |
envVarName | ) |
|
Adds search path from an environment variable.
- Parameters
-
[in] | envVarName | Name of the environment variable to use. |
- Exceptions
-
std::bad_alloc | if out of memory. |
If the specified environment variable is set, it is interpreted like a PATH
environment variable on the platform (split at appropriate separators), and each path found is added to the search path this finder searches. The added paths take precedence over the default directory specified by the global program context, but the current directory is searched first.
The documentation for this class was generated from the following files: