pub struct StandardPaths { /* private fields */ }Expand description
Stores application and organization names and provides all the crate methods.
Implementations§
Source§impl StandardPaths
impl StandardPaths
Sourcepub fn new<S>(app: S, org: S) -> StandardPaths
pub fn new<S>(app: S, org: S) -> StandardPaths
Constructs a new StandardPaths with the provided app and org names.
Sourcepub fn without_org<S>(app: S) -> StandardPaths
pub fn without_org<S>(app: S) -> StandardPaths
Constructs a new StandardPaths with the provided app name and with an empty organization.
Sourcepub fn writable_location(
&self,
location: LocationType,
) -> Result<PathBuf, Error>
pub fn writable_location( &self, location: LocationType, ) -> Result<PathBuf, Error>
Sourcepub fn standard_locations(
&self,
location: LocationType,
) -> Result<Vec<PathBuf>, Error>
pub fn standard_locations( &self, location: LocationType, ) -> Result<Vec<PathBuf>, Error>
Returns all the directories of type location.
The vector of locations is sorted by priority, starting with self.writable location if it can be determined.
Returns Error if the locations cannot be determined or
an empty vector if no locations for the provided type are defined.
§Arguments
location- location type.
Sourcepub fn find_executable<S>(name: S) -> Option<Vec<PathBuf>>
pub fn find_executable<S>(name: S) -> Option<Vec<PathBuf>>
Returns the absolute file path to the executable with name in the system path.
It also could be used to check a path to be an executable.
Internally it calls the
[self.find_executable_in_paths]
method with the system path as the paths argument. On most operating systems
the system path is determined by the PATH environment variable.
Note: on Windows the executable extensions from the PATHEXT environment variable
are automatically appended to the name if it doesn’t contain any extension.
Returns None if no executables are found or if the provided path is not executable.
§Arguments
name- the name of the searched executable or an absolute path which should be checked to be executable.
Sourcepub fn find_executable_in_paths<S, P>(name: S, paths: P) -> Option<Vec<PathBuf>>
pub fn find_executable_in_paths<S, P>(name: S, paths: P) -> Option<Vec<PathBuf>>
Returns the absolute file path to the executable with name in the provided paths.
Note: on Windows the executable extensions from the PATHEXT environment variable
are automatically appended to the name if it doesn’t contain any extension.
Returns None if no executables are found or if the provided path is not executable.
§Arguments
name- the name of the searched executable or an absolute path which should be checked to be executable.paths- the directories where to search for the executable.
Sourcepub fn locate<P>(
&self,
location: LocationType,
name: P,
option: LocateOption,
) -> Result<Option<PathBuf>, Error>
pub fn locate<P>( &self, location: LocationType, name: P, option: LocateOption, ) -> Result<Option<PathBuf>, Error>
Search for a file or directory called ‘name’ in the standard locations.
Returns a full path to the first file or directory found.
Returns Error if accessing the location failed or
None if no such file or directory can be found.
§Arguments
location- the location type where to search.name- the name of the file or directory to search.option- the type of entry to search.
Sourcepub fn locate_all<P>(
&self,
location: LocationType,
name: P,
option: LocateOption,
) -> Result<Option<Vec<PathBuf>>, Error>
pub fn locate_all<P>( &self, location: LocationType, name: P, option: LocateOption, ) -> Result<Option<Vec<PathBuf>>, Error>
Search for all files or directories called ‘name’ in the standard locations.
Returns a vector of full paths to the all files or directories found.
Returns Error if accessing the location failed or
None if no such files or directories can be found.
§Arguments
location- the location type where to search.name- the name of the files or directories to search.option- the type of entries to search.