use std::fs::create_dir; use crate::cmd::MailStorage; use crate::de_jmhoffmann_jwebmail_mailstorage::{AddFolder_Reply_status, Call_AddFolder}; pub fn add_folder( ms: &MailStorage, call: &mut dyn Call_AddFolder, name: String, ) -> varlink::Result<()> { if let Some(mut p) = ms.maildir_path.read().unwrap().clone() { let mut folder = ".".to_owned(); folder.push_str(&name); p.push(folder); if p.is_dir() { return call.reply(AddFolder_Reply_status::skiped); } create_dir(&p).map_err(varlink::map_context!())?; p.push("tmp"); create_dir(&p).map_err(varlink::map_context!())?; p.pop(); p.push("new"); create_dir(&p).map_err(varlink::map_context!())?; p.pop(); p.push("cur"); create_dir(p).map_err(varlink::map_context!())?; call.reply(AddFolder_Reply_status::created) } else { call.reply_not_initialized() } }