aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils.rs
diff options
context:
space:
mode:
authorNathan Jaremko2017-07-26 16:47:13 -0400
committerNathan Jaremko2017-07-26 16:47:13 -0400
commit4ff4a4e802595f2fac1175c6cb62bb49c6ffda64 (patch)
treebd5f826e1f01c99c474c6e48ac667780e5e42f3d /src/utils.rs
parentcd7b8cb559199c609331b5851076f5a0ed9e1d54 (diff)
downloadpodcast-4ff4a4e802595f2fac1175c6cb62bb49c6ffda64.tar.bz2
Transfer all work from chromebook
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()
- );
+ );
}
}
}