mirror of
https://github.com/librespot-org/librespot.git
synced 2025-10-04 18:29:45 +02:00
core API: move mkdir_existing to cache.rs
This commit is contained in:
parent
77882836ce
commit
d7fa1464ff
2 changed files with 16 additions and 16 deletions
|
@ -1,8 +1,11 @@
|
|||
use std::path::PathBuf;
|
||||
use std::io::Read;
|
||||
use std::fs;
|
||||
use std::fs::File;
|
||||
use std::io;
|
||||
use std::io::Read;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use util::{FileId, mkdir_existing};
|
||||
use util::FileId;
|
||||
use authentication::Credentials;
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -11,6 +14,16 @@ pub struct Cache {
|
|||
use_audio_cache: bool,
|
||||
}
|
||||
|
||||
fn mkdir_existing(path: &Path) -> io::Result<()> {
|
||||
fs::create_dir(path).or_else(|err| {
|
||||
if err.kind() == io::ErrorKind::AlreadyExists {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
impl Cache {
|
||||
pub fn new(location: PathBuf, use_audio_cache: bool) -> Cache {
|
||||
mkdir_existing(&location).unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue