ATLAS Offline Software
Loading...
Searching...
No Matches
PathResolver_page
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

  • 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:

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);
    }
    static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
    int main()
    Definition hello.cxx:18

  2. 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);
    }
    static std::string find_file_from_list(const std::string &logical_file_name, const std::string &search_list)

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);
    }
    static std::string find_directory(const std::string &logical_file_name, const std::string &search_path)