hexed 0.3.0
 
Loading...
Searching...
No Matches
hexed::Path Class Reference

Finds a file in the working directory or system paths. More...

#include <Path.hpp>

Public Types

using path = std::filesystem::path
 convenience alias for std::filesystem::path
 

Public Member Functions

 Path (path subdir={})
 Constructs a Path object with subdir appended to all search paths.
 
std::vector< pathpaths ()
 Returns the list of system paths to search, including the subdir suffix.
 
path find (path target, std::vector< path > extra_dirs={{"."}})
 finds the file target
 

Detailed Description

Finds a file in the working directory or system paths.

The "system paths" are:

  • /
  • /local
  • /usr
  • usr/local
  • $HOME
  • $HOME/.local

Constructor & Destructor Documentation

◆ Path()

hexed::Path::Path ( path subdir = {})

Constructs a Path object with subdir appended to all search paths.

E.g., if the file your looking for is a shared library, you probably want to do subdir = "lib".

Member Function Documentation

◆ find()

Path::path hexed::Path::find ( path target,
std::vector< path > extra_dirs = {{"."}} )

finds the file target

If target is a relative path, it will be searched for in the following directories are searched, in order of precedence:

  • All directories in extra_dirs, which defaults to the current working directory
  • All directories in the environment variable HEXEDPATH, which should be a colon-separated list, if it is set
  • All the system paths, defined above

If target is not found, the return value is an empty path. If target is an absolute path, it will be returned if it exists and the empty path will be returned otherwise.


The documentation for this class was generated from the following files: