Mountain/IPC/WindServiceHandlers/FileSystem/Native/
FileMkdirNative.rs1use serde_json::{Value, json};
5
6use crate::{IPC::WindServiceHandlers::Utilities::PathExtraction::Fn as extract_path_from_arg, dev_log};
7
8pub async fn Fn(Arguments:Vec<Value>) -> Result<Value, String> {
9 let Path = extract_path_from_arg(Arguments.get(0).ok_or("Missing directory path")?)?;
10
11 tokio::fs::create_dir_all(&Path)
12 .await
13 .map_err(|E| format!("Failed to mkdir: {} ({})", Path, E))?;
14
15 dev_log!("vfs", "file:mkdir ok path={}", Path);
16
17 let FileUri = format!("file://{}", Path);
18
19 tokio::spawn(async move {
20 if let Err(Error) = crate::Vine::Client::SendNotification::Fn(
21 "cocoon-main".to_string(),
22 "$acceptDidCreateFiles".to_string(),
23 json!({ "files": [{ "uri": FileUri }] }),
24 )
25 .await
26 {
27 dev_log!(
28 "vfs",
29 "warn: [FileMkdirNative] $acceptDidCreateFiles notify failed: {:?}",
30 Error
31 );
32 }
33 });
34
35 Ok(Value::Null)
36}