aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils.rs')
-rw-r--r--src/utils.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/utils.rs b/src/utils.rs
index 7d355b3..5444cb1 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -3,6 +3,8 @@ use std::env;
use std::fs;
use std::num::ParseIntError;
use std::path::PathBuf;
+use std::fs::DirBuilder;
+use std::io;
pub fn trim_extension(filename: &str) -> String {
@@ -26,6 +28,20 @@ pub fn find_extension(input: &str) -> Option<&str> {
}
}
+pub fn create_directories() -> io::Result<()> {
+ let mut path = get_podcast_dir();
+ path.push(".rss");
+ if let Err(err) = DirBuilder::new().recursive(true).create(&path) {
+ eprintln!(
+ "Couldn't create directory: {}\nReason: {}",
+ path.to_str().unwrap(),
+ err
+ );
+ return Err(err)
+ }
+ Ok(())
+}
+
pub fn already_downloaded(dir: &str) -> HashSet<String> {
let mut result = HashSet::new();
@@ -45,7 +61,7 @@ pub fn already_downloaded(dir: &str) -> HashSet<String> {
println!(
"OsString: {:?} couldn't be converted to String",
entry.file_name()
- );
+ );
}
}
}