Skip to content

Commit fb4a24f

Browse files
refactor(Mountain): Simplify binary names and split monolithic IPC handlers
Rename the Cargo binary and lib from the verbose development profile name to simply 'Mountain', matching the tauri.conf.json productName simplification. Concurrently, decompose the monolithic NativeHost.rs into 10 domain-specific handler files under WindServiceHandlers/NativeHost/ (FindFreePort, GetColorScheme, IsFullscreen, IsMaximized, OpenExternal, OSProperties, OSStatistics, PickFolder, ShowItemInFolder, ShowOpenDialog). Also introduce a new FileSystem module split into Managed (trait-based) and Native (tokio::fs) tiers, each with their own atom handlers. Update mod.rs to replace the NativeHost glob import with explicit submodule paths, consistent with the reverse-hierarchical path pattern enforced in recent commits.
1 parent e3135b9 commit fb4a24f

42 files changed

Lines changed: 1280 additions & 905 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[[bin]]
2-
name = "DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_Mountain"
2+
name = "Mountain"
33
path = "Source/Library.rs"
44

55
[build-dependencies]
@@ -148,7 +148,7 @@ TierOpenExternalLayer4 = []
148148
TierExtensionScanParallel = []
149149

150150
[lib]
151-
name = "DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_Mountain"
151+
name = "Mountain"
152152
path = "Source/Library.rs"
153153
crate-type = ["lib", "staticlib"]
154154

@@ -158,11 +158,11 @@ autobenches = false
158158
autobins = false
159159
autoexamples = false
160160
autotests = false
161-
default-run = "DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_Mountain"
161+
default-run = "Mountain"
162162
description = "Mountain ⛰️"
163163
edition = "2021"
164164
license-file = "LICENSE"
165-
name = "DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_Mountain"
165+
name = "Mountain"
166166
publish = false
167167
include = [
168168
"build.rs",

Cargo.toml.Backup

Lines changed: 0 additions & 192 deletions
This file was deleted.

Source/ApplicationState/DTO/DocumentStateDTO.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use serde::{Deserialize, Serialize};
2525
use serde_json::Value;
2626
use url::Url;
2727

28-
use crate::{ApplicationState::Internal::TextProcessing::AnalyzeTextLinesAndEOL, dev_log};
28+
use crate::{ApplicationState::Internal::TextProcessing::AnalyzeTextLinesAndEOL::AnalyzeTextLinesAndEOL, dev_log};
2929
use super::{RPCModelContentChangeDTO::RPCModelContentChangeDTO, RPCRangeDTO::RPCRangeDTO};
3030

3131
/// Maximum line count for a document to prevent memory exhaustion
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#![allow(non_snake_case, unused_variables, dead_code, unused_imports)]
2+
3+
//! Legacy wire method `file:copy`. Non-overwriting.
4+
5+
use std::{path::PathBuf, sync::Arc};
6+
7+
use CommonLibrary::{
8+
Environment::Requires::Requires,
9+
Error::CommonError::CommonError,
10+
FileSystem::FileSystemWriter::FileSystemWriter,
11+
};
12+
use serde_json::Value;
13+
14+
use crate::{RunTime::ApplicationRunTime::ApplicationRunTime, dev_log};
15+
16+
pub async fn handle_file_copy(runtime:Arc<ApplicationRunTime>, args:Vec<Value>) -> Result<Value, String> {
17+
let source = args
18+
.get(0)
19+
.ok_or("Missing source path".to_string())?
20+
.as_str()
21+
.ok_or("Source path must be a string".to_string())?;
22+
23+
let destination = args
24+
.get(1)
25+
.ok_or("Missing destination path".to_string())?
26+
.as_str()
27+
.ok_or("Destination path must be a string".to_string())?;
28+
29+
let provider:Arc<dyn FileSystemWriter> = runtime.Environment.Require();
30+
31+
provider
32+
.Copy(&PathBuf::from(source), &PathBuf::from(destination), false)
33+
.await
34+
.map_err(|e:CommonError| format!("Failed to copy file: {} -> {}", source, destination))?;
35+
36+
dev_log!("vfs", "copied: {} -> {}", source, destination);
37+
Ok(Value::Null)
38+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#![allow(non_snake_case, unused_variables, dead_code, unused_imports)]
2+
3+
//! Legacy wire method `file:delete`. Non-recursive, non-trash.
4+
5+
use std::{path::PathBuf, sync::Arc};
6+
7+
use CommonLibrary::{
8+
Environment::Requires::Requires,
9+
Error::CommonError::CommonError,
10+
FileSystem::FileSystemWriter::FileSystemWriter,
11+
};
12+
use serde_json::Value;
13+
14+
use crate::{RunTime::ApplicationRunTime::ApplicationRunTime, dev_log};
15+
16+
pub async fn handle_file_delete(runtime:Arc<ApplicationRunTime>, args:Vec<Value>) -> Result<Value, String> {
17+
let path = args
18+
.get(0)
19+
.ok_or("Missing file path".to_string())?
20+
.as_str()
21+
.ok_or("File path must be a string".to_string())?;
22+
23+
let provider:Arc<dyn FileSystemWriter> = runtime.Environment.Require();
24+
25+
provider
26+
.Delete(&PathBuf::from(path), false, false)
27+
.await
28+
.map_err(|e:CommonError| format!("Failed to delete file: {}", e))?;
29+
30+
dev_log!("vfs", "deleted: {}", path);
31+
Ok(Value::Null)
32+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#![allow(non_snake_case, unused_variables, dead_code, unused_imports)]
2+
3+
//! Legacy wire method `file:exists`. Returns bool via `StatFile` probe.
4+
5+
use std::{path::PathBuf, sync::Arc};
6+
7+
use CommonLibrary::{Environment::Requires::Requires, FileSystem::FileSystemReader::FileSystemReader};
8+
use serde_json::{Value, json};
9+
10+
use crate::{RunTime::ApplicationRunTime::ApplicationRunTime, dev_log};
11+
12+
pub async fn handle_file_exists(runtime:Arc<ApplicationRunTime>, args:Vec<Value>) -> Result<Value, String> {
13+
let path = args
14+
.get(0)
15+
.ok_or("Missing file path".to_string())?
16+
.as_str()
17+
.ok_or("File path must be a string".to_string())?;
18+
19+
let provider:Arc<dyn FileSystemReader> = runtime.Environment.Require();
20+
21+
let exists = provider.StatFile(&PathBuf::from(path)).await.is_ok();
22+
23+
dev_log!("vfs", "exists: {} = {}", path, exists);
24+
Ok(json!(exists))
25+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#![allow(non_snake_case, unused_variables, dead_code, unused_imports)]
2+
3+
//! Legacy wire method `file:mkdir`. Recursive by default
4+
//! (`args[1]` honoured when supplied as bool).
5+
6+
use std::{path::PathBuf, sync::Arc};
7+
8+
use CommonLibrary::{
9+
Environment::Requires::Requires,
10+
Error::CommonError::CommonError,
11+
FileSystem::FileSystemWriter::FileSystemWriter,
12+
};
13+
use serde_json::Value;
14+
15+
use crate::{RunTime::ApplicationRunTime::ApplicationRunTime, dev_log};
16+
17+
pub async fn handle_file_mkdir(runtime:Arc<ApplicationRunTime>, args:Vec<Value>) -> Result<Value, String> {
18+
let path = args
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 = args.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", "mkdir: {} (recursive: {})", path, recursive);
34+
Ok(Value::Null)
35+
}

0 commit comments

Comments
 (0)