|
| 1 | +// --------------------------------------------------------------------------------------------- |
| 2 | +// Mountain Native FS Handlers (handlers/native_fs.rs) - DEPRECATED (Path A) |
| 3 | +// -------------------------------------------------------------------------------------------- |
| 4 | +// This file previously handled low-level filesystem requests proxied directly |
| 5 | +// from Cocoon's Node 'fs' module shim (using `fs_*` method names). |
| 6 | +// |
| 7 | +// CURRENT STATUS (Path A with workspace.fs): **DEPRECATED/UNUSED** |
| 8 | +// With the implementation of the `vscode.workspace.fs` API shim |
| 9 | +// (`fs-api-shim.js`) and corresponding Mountain handlers |
| 10 | +// (`handlers/workspace_fs_api.rs`) which delegate to the Environment |
| 11 | +// implementation (`environment.rs`), direct proxying of the Node 'fs' |
| 12 | +// module implemented here is **not used** in the primary MVP Path A flow. |
| 13 | +// |
| 14 | +// Extensions *should* use `vscode.workspace.fs`. If direct Node 'fs' access |
| 15 | +// were re-enabled, these handlers would need significant updates, including |
| 16 | +// security checks and alignment with the Environment's FS capabilities. |
| 17 | +// |
| 18 | +// This file is kept for historical reference only and its functions should not |
| 19 | +// be called. |
| 20 | +// -------------------------------------------------------------------------------------------- |
| 21 | + |
| 22 | +// ----- START: DEPRECATED Element/Mountain/src/handlers/native_fs.rs ----- |
| 23 | +// NOTE: This entire file is DEPRECATED for Path A (vscode.workspace.fs) |
| 24 | + |
| 25 | +use std::path::PathBuf; |
| 26 | + |
| 27 | +// These imports might not be needed if the file is truly unused, but kept for context |
| 28 | +use Land_River::api as river_api; |
| 29 | +use Land_Sun::api as sun_api; |
| 30 | +// Use log crate if logging warnings about deprecation |
| 31 | +use log; |
| 32 | +use serde_json::{Value, json}; |
| 33 | +use tauri::{AppHandle, Runtime, Window}; |
| 34 | + |
| 35 | +const DEPRECATED_ERROR_MSG:&str = "Native FS handlers are deprecated; use workspace.fs API via effects/environment."; |
| 36 | + |
| 37 | +// --- Helper Functions (remain unchanged, but unused in Path A) --- |
| 38 | +fn create_error_string(message:String, code:Option<&str>) -> String { |
| 39 | + json!({ "message": message, "code": code.unwrap_or("EUNKNOWN") }).to_string() |
| 40 | +} |
| 41 | + |
| 42 | +// Returns error immediately as path parsing is not relevant for deprecated |
| 43 | +// handlers |
| 44 | +fn path_from_uri_components(_params:&Value) -> Result<PathBuf, String> { |
| 45 | + Err(create_error_string(DEPRECATED_ERROR_MSG.to_string(), Some("ENOSYS"))) |
| 46 | +} |
| 47 | + |
| 48 | +// --- Direct Action Handlers (remain deprecated stubs) --- |
| 49 | +/// **DEPRECATED:** Use `workspace.fs` API effects instead. |
| 50 | +pub async fn handle_read_file<R:Runtime>(/* ... */) -> Result<Value, String> { |
| 51 | + log::warn!("[FS Handler - DEPRECATED] Direct handle_read_file called."); |
| 52 | + |
| 53 | + Err(create_error_string(DEPRECATED_ERROR_MSG.to_string(), Some("ENOSYS"))) |
| 54 | +} |
| 55 | + |
| 56 | +/// **DEPRECATED:** Use `workspace.fs` API effects instead. |
| 57 | +pub async fn handle_write_file<R:Runtime>(/* ... */) -> Result<Value, String> { |
| 58 | + log::warn!("[FS Handler - DEPRECATED] Direct handle_write_file called."); |
| 59 | + |
| 60 | + Err(create_error_string(DEPRECATED_ERROR_MSG.to_string(), Some("ENOSYS"))) |
| 61 | +} |
| 62 | + |
| 63 | +// --- Proxied Handlers (remain deprecated stubs) --- |
| 64 | +/// **DEPRECATED:** Use `workspace.fs` API effects instead. |
| 65 | +pub async fn handle_fs_stat(_params:Value) -> Result<Value, String> { |
| 66 | + log::warn!("[FS Handler Proxy - DEPRECATED] handle_fs_stat called."); |
| 67 | + |
| 68 | + Err(create_error_string(DEPRECATED_ERROR_MSG.to_string(), Some("ENOSYS"))) |
| 69 | +} |
| 70 | + |
| 71 | +/// **DEPRECATED:** Use `workspace.fs` API effects instead. |
| 72 | +pub async fn handle_fs_realpath(_params:Value) -> Result<Value, String> { |
| 73 | + log::warn!("[FS Handler Proxy - DEPRECATED] handle_fs_realpath called."); |
| 74 | + |
| 75 | + Err(create_error_string(DEPRECATED_ERROR_MSG.to_string(), Some("ENOSYS"))) |
| 76 | +} |
| 77 | + |
| 78 | +/// **DEPRECATED:** Use `workspace.fs` API effects instead. |
| 79 | +pub async fn handle_fs_read_file_proxy(_params:Value) -> Result<Value, String> { |
| 80 | + log::warn!("[FS Handler Proxy - DEPRECATED] handle_fs_read_file_proxy called."); |
| 81 | + |
| 82 | + Err(create_error_string(DEPRECATED_ERROR_MSG.to_string(), Some("ENOSYS"))) |
| 83 | +} |
| 84 | + |
| 85 | +/// **DEPRECATED:** Use `workspace.fs` API effects instead. |
| 86 | +pub async fn handle_fs_write_file_proxy(_params:Value) -> Result<Value, String> { |
| 87 | + log::warn!("[FS Handler Proxy - DEPRECATED] handle_fs_write_file_proxy called."); |
| 88 | + |
| 89 | + Err(create_error_string(DEPRECATED_ERROR_MSG.to_string(), Some("ENOSYS"))) |
| 90 | +} |
| 91 | + |
| 92 | +/// **DEPRECATED:** Use `workspace.fs` API effects instead. |
| 93 | +pub async fn handle_fs_mkdir_proxy(_params:Value) -> Result<Value, String> { |
| 94 | + log::warn!("[FS Handler Proxy - DEPRECATED] handle_fs_mkdir_proxy called."); |
| 95 | + |
| 96 | + Err(create_error_string(DEPRECATED_ERROR_MSG.to_string(), Some("ENOSYS"))) |
| 97 | +} |
| 98 | + |
| 99 | +/// **DEPRECATED:** Use `workspace.fs` API effects instead. |
| 100 | +pub async fn handle_fs_unlink_proxy(_params:Value) -> Result<Value, String> { |
| 101 | + log::warn!("[FS Handler Proxy - DEPRECATED] handle_fs_unlink_proxy called."); |
| 102 | + |
| 103 | + Err(create_error_string(DEPRECATED_ERROR_MSG.to_string(), Some("ENOSYS"))) |
| 104 | +} |
| 105 | + |
| 106 | +// ... Add similar stubs for any other fs_* proxy handlers that existed ... |
| 107 | +// pub async fn handle_fs_readdir_proxy(...) -> Result<Value, String> { Err(...) |
| 108 | +// } pub async fn handle_fs_rename_proxy(...) -> Result<Value, String> { |
| 109 | + |
| 110 | +// Err(...) } pub async fn handle_fs_copy_proxy(...) -> Result<Value, String> { |
| 111 | + |
| 112 | +// Err(...) } pub async fn handle_fs_exists_proxy(...) -> Result<Value, String> |
| 113 | +// { Err(...) } |
| 114 | + |
| 115 | +// ----- END: DEPRECATED Element/Mountain/src/handlers/native_fs.rs ----- |
0 commit comments