fn file_and_path(
    out_path: &Path,
    name: &str,
    overwrite: bool,
) -> Result<(File, PathBuf), anyhow::Error> {
    let default = |file_name: &str| -> Result<(File, PathBuf), anyhow::Error> {
        Ok((
            File::create(&out_path.join(&file_name))?,
            out_path.join(file_name),
        ))
    };

    let (output, output_path) = if out_path.join(&name).exists() {
        if overwrite {
            info!("Overwrite is enabled. Any file with the same name ({}) will be overwritten by the output file", &name);
            default(name)?
        } else {
            warn!("Overwrite is disabled. File with a similar name found. Modifying name.");
            let bind = format!("{}_{}", random_name(), &name);
            default(&bind)?
        }
    } else {
        default(name)?
    };
    Ok((output, output_path))
}
/// Returns the File and the path of the file.
///
/// This takes into account if the overwrite flag was enabled.
///
/// If overwrite was disabled, custom name specified, and a file with a similar name was found,
/// prepends a random name using [`random_name()`].
///
/// # Errors
/// Returns an error if the file creation fails.
Returns the File and the path of the file.
This takes into account if the overwrite flag was enabled.

If overwrite was disabled, custom name specified, and a file with a similar name was found,
prepends a random name using [`random_name()`].
Returns the File and the path of the file . This takes into account if the overwrite flag was enabled . If overwrite was disabled custom name specified and a file with a similar name was found prepends a random name using [ ` random_name () ` ] .
fn file_and_path(
    out_path: &Path,
    name: &str,
    overwrite: bool,
) -> Result<(File, PathBuf), anyhow::Error> {
    let default = |file_name: &str| -> Result<(File, PathBuf), anyhow::Error> {
        Ok((
            File::create(&out_path.join(&file_name))?,
            out_path.join(file_name),
        ))
    };
    let (output, output_path) = if out_path.join(&name).exists() {
        if overwrite {
            info!("Overwrite is enabled. Any file with the same name ({}) will be overwritten by the output file", &name);
            default(name)?
        } else {
            warn!("Overwrite is disabled. File with a similar name found. Modifying name.");
            let bind = format!("{}_{}", random_name(), &name);
            default(&bind)?
        }
    } else {
        default(name)?
    };
    Ok((output, output_path))
}
fn file_and_path ( out_path : & Path , name : & str , overwrite : bool , ) -> Result < ( File , PathBuf ) , anyhow :: Error > { let default = | file_name : & str | -> Result < ( File , PathBuf ) , anyhow :: Error > { Ok ( ( File :: create ( & out_path . join ( & file_name ) ) ? , out_path . join ( file_name ) , ) ) } ; let ( output , output_path ) = if out_path . join ( & name ) . exists ( ) { if overwrite { info ! ( " " name ) ; default ( name ) ? } else { warn ! ( " " ) ; let bind = format ! ( " " random_name ( ) name ) ; default ( & bind ) ? } } else { default ( name ) ? } ; Ok ( ( output , output_path ) ) }
Returns the File and the path of the file.
Returns the File and the path of the file .
out_path
&Path
name
&str
overwrite
bool
out_path
&Path
name
&str
overwrite
bool
errors
Returns an error if the file creation fails.
Returns an error if the file creation fails .