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