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