All checks were successful
Rust Build / Test Suite (push) Successful in 28s
Release Tagging / release (push) Successful in 36s
Rust Build / Check (push) Successful in 43s
Rust Build / Rustfmt (push) Successful in 24s
Rust Build / build (push) Successful in 26s
Rust Build / Clippy (push) Successful in 35s
Closes #76 Reviewed-on: #81 Co-authored-by: phoenix <kundeng00@pm.me> Co-committed-by: phoenix <kundeng00@pm.me>
20 lines
519 B
Rust
20 lines
519 B
Rust
pub fn concatenate_path(
|
|
directory: &str,
|
|
filename: &str,
|
|
last_index: usize,
|
|
) -> Result<String, std::io::Error> {
|
|
if let Some(character) = directory.chars().nth(last_index) {
|
|
let buffer: String = if character != '/' {
|
|
format!("{directory}/")
|
|
} else {
|
|
String::from(directory)
|
|
};
|
|
|
|
Ok(format!("{buffer}{filename}"))
|
|
} else {
|
|
Err(std::io::Error::other(
|
|
crate::constants::error::LAST_CHARACTER_IN_DIRECTORY,
|
|
))
|
|
}
|
|
}
|