Added function to save song to the filesystem
This commit is contained in:
25
src/song.rs
25
src/song.rs
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user