1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use crate::{Result, Value};

use std::fs;

pub fn create(arg: &Value) -> Result<Value> {
    let path = arg.as_string()?;
    fs::create_dir_all(path)?;

    Ok(Value::Empty)
}

pub fn read(arg: &Value) -> Result<Value> {
    let path = arg.as_string()?;

    let file_list = fs::read_dir(path)?
        .map(|entry| {
            let file_name = entry.unwrap().file_name().into_string().unwrap();
            format!("{}\n", file_name)
        })
        .collect::<String>();

    Ok(Value::String(file_list))
}

pub fn remove() -> Result<Value> {
    Ok(Value::Empty)
}