Struct standard_paths::StandardPaths
source · 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) -> StandardPathswhere
S: Into<String>,
pub fn new<S>(app: S, org: S) -> StandardPathswhere S: Into<String>,
Constructs a new StandardPaths
with the provided app
and org
names.
sourcepub fn without_org<S>(app: S) -> StandardPathswhere
S: Into<String>,
pub fn without_org<S>(app: S) -> StandardPathswhere S: Into<String>,
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>>where
S: Into<String>,
pub fn find_executable<S>(name: S) -> Option<Vec<PathBuf>>where S: Into<String>,
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>>where
S: Into<String>,
P: AsRef<Vec<PathBuf>>,
pub fn find_executable_in_paths<S, P>(name: S, paths: P) -> Option<Vec<PathBuf>>where S: Into<String>, P: AsRef<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>where
P: AsRef<Path>,
pub fn locate<P>( &self, location: LocationType, name: P, option: LocateOption ) -> Result<Option<PathBuf>, Error>where P: AsRef<Path>,
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>where
P: AsRef<Path>,
pub fn locate_all<P>( &self, location: LocationType, name: P, option: LocateOption ) -> Result<Option<Vec<PathBuf>>, Error>where P: AsRef<Path>,
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.