tsk-76: Improve getting path of Song or CoverArt (#81)
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
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>
This commit was merged in pull request #81.
This commit is contained in:
19
src/util/mod.rs
Normal file
19
src/util/mod.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
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,
|
||||
))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user