tsk-73: Code cleanup:

:
This commit is contained in:
2025-10-18 21:00:38 -04:00
parent 3ee3ac737b
commit 580f5e9be7

View File

@@ -71,21 +71,22 @@ impl Song {
pub fn song_path(&self) -> Result<String, std::io::Error> { pub fn song_path(&self) -> Result<String, std::io::Error> {
if self.directory.is_empty() { if self.directory.is_empty() {
return Err(std::io::Error::other("Directory does not exist")); return Err(std::io::Error::other("Directory has not been initialized"));
} else if self.filename.is_empty() {
return Err(std::io::Error::other("Filename has not bee initialized"));
} }
let directory = &self.directory; let directory = &self.directory;
let mut buffer: String = directory.clone();
let last_index = directory.len() - 1; let last_index = directory.len() - 1;
if let Some(character) = directory.chars().nth(last_index) { if let Some(character) = directory.chars().nth(last_index) {
if character != '/' { let buffer: String = if character != '/' {
buffer += "/"; directory.clone() + "/"
} } else {
directory.clone()
};
buffer += &self.filename.clone(); Ok(buffer + &self.filename.clone())
Ok(buffer)
} else { } else {
Err(std::io::Error::other( Err(std::io::Error::other(
"Could not access last character of directory", "Could not access last character of directory",