Crate easy_paths

Source

Functions§

are_paths_the_same
Returns true if both paths are pointing to the same dir / file on the disk If relative paths are used, this fetches the cwd. This assumes if a relative path is passed, the root dir of the working area is the project
are_paths_the_same_assume_cwd
Returns true if both paths are pointing to the same dir / file on the disk If relative paths are used, this assumes the working directory is cwd Due to the cwd fetch’s potential for errors, this function requires unpacking
are_paths_the_same_assume_project_dir
Returns true if both paths are pointing to the same dir / file on the disk If relative paths are used, this fetches the cwd. If a relative path is used, this assumes the working directory is the project’s root
get_absolute_path
This attempts to get the full path
get_absolute_path_or_error
Similar to get_absolute_path() except this is ‘all-or-nothing.’ If any step fails, this returns an error message explaining which step failed. Since canonicalize requires the final path to exist, this will count as a ‘failure’ condition. This supports ‘~’, ‘.’, ‘..’
get_base_name
Returns a string consisting of only the filename Returns None in case of failure
get_common_path
Returns a string path which is shared between all paths in the slice of string-like values If the common path doesn’t exist, the function will then iterate upwards through the common path’s ancestors until to a path is found, or no further parents exist. Returns None in case of failure (either no match found, nothing about the common string exists)
get_common_prefix
Returns a string or None which is the same shared path represented within a slice of string-like paths
get_dir_ancestor_n_levels_up
Returns a string or None which is the path n-layers up
get_dir_ancestor_that_exists
Returns a string or None which is the part of the argument path that actually exists
get_dir_cwd
Returns a string or None which is the path to the current working directory
get_dir_name
Returns a string or None which is the path to the current working directory
get_dir_proj_root
Returns a string representing the path to the project root directory
get_extension
Returns a string representing the file extension without the period
get_file_path_binary
Returns a string path pointing at the binary file created by the compilation process
get_only_dirs_from_slice
Returns a vec of only strings referencing directories from a slice argument
get_only_file_paths_from_slice
Returns a vec of only strings referencing files from a slice argument
get_path_buf_from_type_string
Returns PathBuf created from a string-like argument
get_path_joined
Returns a string path that is the result of combining a slice of string-like values In case of a failure, this returns None
get_path_with_tilde_expanded_if_necessary
Returns a string with the ‘~’ expanded within the path
get_paths_in_dir
Returns a vec of string paths inside directory In case of a failure, this returns an error explaining what happened
get_paths_in_dir_and_sub_dirs
Returns a vec of string paths inside directory In case of a failure, this returns an error explaining what happened
get_paths_sorted_by_size_starting_with_shortest
Returns a vec of string paths, sorted by their depth, with the shortest first
get_paths_to_only_dirs_in_dir_and_sub_dirs
Returns a vec of string paths inside directory In case of a failure, this returns an error explaining what happened
get_paths_to_only_files_in_dir_and_sub_dirs
Returns a vec of string paths inside directory In case of a failure, this returns an error explaining what happened
get_relative_path
Returns a string that’s a relative path after the prefix is removed In case of a failure, this returns an error explaining what happened
get_string_from_type_dir_entry
Returns a String extracted from DirEntry In case of failure, this returns None
get_string_from_type_osstr
Returns String extracted from OsStr Returns None in case of failure
get_string_from_type_path
Returns String extracted from Path Returns None in case of failure
get_string_from_type_path_buf
Returns String extracted from PathBuf Returns None in case of failure
get_vec_by_splitting_path
Returns a vec resulting from splitting the path into substrings Returns None in case of failure
has_parent
Returns true if the path argument has a parent, and false if not
is_absolute
Returns true if the string is an absolute path
is_dir
Returns bool is path is a directory
is_existing_path
Returns bool is path is a directory
is_file
Returns bool is path is a directory
is_path_buf_type
Returns true if arg is type PathBuf
is_path_inside_dir_parent
Returns true if arg_string_path is inside arg_string_dir_parent
is_path_type
Returns true if arg is type Path
raise_error_if_path_does_not_exist
Returns an error if one is detected. Otherwise, this returns None
raise_error_if_path_is_not_in_project
Returns an error if arg_string_path points to a location outside the project. Otherwise, this returns None.
raise_error_if_path_points_to_cargo_toml
Returns an error if arg_string_path points to Cargo.toml within project. Otherwise, this returns None.
raise_error_if_path_points_to_main_rs
Returns an error if arg_string_path points at main.rs in the project. Otherwise, this returns None.
raise_error_if_path_points_to_project_root
Returns an error if arg_string_path points to project directory. Otherwise, this returns None.
raise_error_if_path_points_to_src
Returns an error if arg_string_path points to src within project. Otherwise, this returns None. If the path is relative, then the