pub fn get_dir_path_buf() -> Result<PathBuf, FractalError>
Expand description
Returns a PathBuf
representing a directory path.
This function determines the appropriate directory path based on the current mode (debug or release) and an optional workspace directory. In release mode, it returns the current working directory. In debug mode, it recursively determines the workspace directory, appending “target” to it.
§Parameters
is_debug_mode
: A boolean indicating whether the function is running in debug mode.workspace_dir
: An optionalPathBuf
representing the workspace directory.
§Returns
std::result::Result<PathBuf, io::Error>
Ok(PathBuf)
: The directory path asPathBuf
.Err(io::Error)
: An error occurred while determining the directory path.
§Examples
use shared::utils::filesystem::get_dir_path_buf;
// Retrieve the directory path in the current mode
let path_buf = get_dir_path_buf().expect("Failed to get directory path");
println!("Directory Path: {:?}", path_buf);
§Note
This function uses a recursive approach in debug mode to determine the workspace directory. It may append “target” to the workspace directory in this case.