summaryrefslogtreecommitdiffstats
path: root/src/commands/new_directory.rs
blob: 2c5fd57190b083cffbd1daaacff5fec7ddb582df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::path;

use crate::context::JoshutoContext;
use crate::error::JoshutoResult;
use crate::history::DirectoryHistory;
use crate::util::load_child::LoadChild;

pub fn new_directory(context: &mut JoshutoContext, p: &path::Path) -> JoshutoResult<()> {
    std::fs::create_dir_all(p)?;
    let options = context.config_t.sort_option.clone();
    let curr_path = context.tab_context_ref().curr_tab_ref().pwd().to_path_buf();
    for tab in context.tab_context_mut().iter_mut() {
        tab.history_mut().reload(&curr_path, &options)?;
    }
    LoadChild::load_child(context)?;
    Ok(())
}