pub fn get_file_path(
filename: &str,
path: PathBuf,
extension: &str,
) -> Result<String, FractalError>
Expand description
Generates a file path string with a random component in the filename. Constructs the path from the given filename, path, and extension. Ensures unique filenames.
§Arguments
filename
- Base filename without extension.path
- PathBuf where the file will be located.extension
- File extension.
§Returns
Returns a Result<String, String>
where Ok
contains the file path, and Err
contains an error message.
§Examples
use std::path::PathBuf;
use shared::utils::filesystem::get_file_path;
let path = PathBuf::from("/some/directory");
match get_file_path("myfile", path, "txt") {
Ok(file_path) => println!("Generated file path: {}", file_path),
Err(e) => println!("Error: {}", e),
}