ATLAS Offline Software
This utility finds files or directories from a search path list.

Principle

Assuming that a path-like environment variable is defined and filled in with the possible prioritized locations where a category of files is to be looked for, this utility will locate any file of that category from those possible locations.

The following properties are implemented:

  • a directory offset can be specified. In this case, the file search will detect files either right in every search path or in the offset directory in every search path.

  • the effective physical location of the file is returned, possibly with symbolic link resolution

  • it is possible to locate regular files or directories

  • the search can be local in every search path or recursive to all subdirectories below every serach path.

  • it is possible to simply verify a search path against non existing entries

  • Search paths can be specified either by giving the name of a path-like environment variable or by a text string containing the path list. In both cases the list follows the specific syntax convention of the operating system (ie ':' on Unix systems and ';' on DOS ones).


Using the PathResolver

Accessing the PathResolver package.

One needs to add to the requirements file the following use statement:

use PathResolver PathResolver-00-* Tools

Finding a file

  1. Finding a data file from the DATAPATH search list:

    int main ()
    {
    std::string name;
    name = PathResolver::find_file ("a.dat", "DATAPATH");
    if (name == "")
    {
    std::cerr << "Cannot locate a.dat from ${DATAPATH}" << std::endl;
    }
    return (0);
    }

  2. Recursively finding a data file from the DATAPATH search list:

    int main ()
    {
    std::string name;
    if (name == "")
    {
    std::cerr << "Cannot locate a.dat from any subdirectory of ${DATAPATH}" << std::endl;
    }
    return (0);
    }

  3. Finding a data file from an explicit search list:

    int main ()
    {
    std::string name;
    name = PathResolver::find_file_from_list ("a.dat", "/here/data:/there/data");
    if (name == "")
    {
    std::cerr << "Cannot locate a.dat from either /here/data or /there/data" << std::endl;
    }
    return (0);
    }

Finding a directory

  1. Finding a directory from the DATAPATH search list:

    int main ()
    {
    std::string name;
    name = PathResolver::find_directory ("data", "DATAPATH");
    if (name == "")
    {
    std::cerr << "Cannot locate data directory from ${DATAPATH}" << std::endl;
    }
    return (0);
    }

PathResolver::RecursiveSearch
@ RecursiveSearch
Definition: PathResolver.h:28
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
Definition: PathResolver.cxx:251
PathResolver::find_directory
static std::string find_directory(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
Definition: PathResolver.cxx:307
main
int main(int, char **)
Main class for all the CppUnit test classes
Definition: CppUnit_SGtestdriver.cxx:141
PathResolver::find_file_from_list
static std::string find_file_from_list(const std::string &logical_file_name, const std::string &search_list, SearchType search_type=LocalSearch)
Definition: PathResolver.cxx:281
PathResolver.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
PathResolver
Definition: PathResolver.h:16