Added function to save song to the filesystem

This commit is contained in:
2025-10-11 14:08:20 -04:00
parent 2d6b550ae6
commit fa8643e73a

View File

@@ -1,4 +1,4 @@
use std::io::Read;
use std::io::{Read,Write};
use crate::constants;
use crate::init;
@@ -150,4 +150,27 @@ impl Song {
filename
}
pub fn save_to_filesystem(&self) -> Result<(), std::io::Error> {
match self.song_path() {
Ok(song_path) => {
match std::fs::File::create(&song_path) {
Ok(mut file) => {
match file.write_all(&self.data) {
Ok(_res) => {
Ok(())
}
Err(err) => {
Err(err)
}
}
}
Err(err) => {
Err(err)
}
}
}
Err(err) => Err(err)
}
}
}