Mountain/IPC/WindServiceHandlers/FileSystem/Native/FileCloneNative.rs
1#![allow(non_snake_case, unused_variables, dead_code, unused_imports)]
2
3//! Wire method `file:copy` / `file:cloneFile`. `tokio::fs::copy`
4//! preserves content but not xattrs/acls; callers that need metadata
5//! should use an OS-specific clone atom (future work).
6
7use serde_json::Value;
8
9use crate::IPC::WindServiceHandlers::Utilities::PathExtraction::extract_path_from_arg;
10
11pub async fn FileCloneNative(Arguments:Vec<Value>) -> Result<Value, String> {
12 let Source = extract_path_from_arg(Arguments.get(0).ok_or("Missing source path")?)?;
13 let Target = extract_path_from_arg(Arguments.get(1).ok_or("Missing target path")?)?;
14
15 tokio::fs::copy(&Source, &Target)
16 .await
17 .map_err(|E| format!("Failed to clone: {} -> {} ({})", Source, Target, E))?;
18
19 Ok(Value::Null)
20}