Mountain/IPC/WindServiceHandlers/FileSystem/Managed/
FileMkdir.rs1use std::{path::PathBuf, sync::Arc};
5
6use CommonLibrary::{
7 Environment::Requires::Requires,
8 Error::CommonError::CommonError,
9 FileSystem::FileSystemWriter::FileSystemWriter,
10};
11use serde_json::Value;
12
13use crate::{
14 IPC::WindServiceHandlers::Utilities::JsonValueHelpers::arg_bool_true,
15 RunTime::ApplicationRunTime::ApplicationRunTime,
16 dev_log,
17};
18
19pub async fn Fn(RunTime:Arc<ApplicationRunTime>, Arguments:Vec<Value>) -> Result<Value, String> {
20 let path = Arguments
21 .get(0)
22 .ok_or("Missing directory path".to_string())?
23 .as_str()
24 .ok_or("Directory path must be a string".to_string())?;
25
26 let recursive = arg_bool_true(&Arguments, 1);
27
28 let provider:Arc<dyn FileSystemWriter> = RunTime.Environment.Require();
29
30 provider
31 .CreateDirectory(&PathBuf::from(path), recursive)
32 .await
33 .map_err(|e:CommonError| format!("Failed to create directory: {}", e))?;
34
35 dev_log!("vfs-verbose", "mkdir: {} (recursive: {})", path, recursive);
36
37 Ok(Value::Null)
38}