diff options
| author | 2026-01-16 20:24:53 +0800 | |
|---|---|---|
| committer | 2026-01-16 20:24:53 +0800 | |
| commit | 853f40dc13e6463bedf30e2471a71bd011be425b (patch) | |
| tree | 6dce37f1ae9a4617fe6c88b00a25e14e6a45f139 /src-tauri/src/utils | |
| parent | 743401f15199a116b1777bced843c774c5a59fba (diff) | |
| download | DropOut-853f40dc13e6463bedf30e2471a71bd011be425b.tar.gz DropOut-853f40dc13e6463bedf30e2471a71bd011be425b.zip | |
feat: implement instance management features and enhance game launch process
Added functionality for managing game instances, including creating, deleting, updating, and duplicating instances. Integrated instance selection into the game launch process, allowing users to specify the instance when starting a game. Updated the main application logic to handle instance states and paths, ensuring proper directory management for each instance. Introduced a new module for instance management and updated relevant commands to support instance-specific operations.
Diffstat (limited to 'src-tauri/src/utils')
| -rw-r--r-- | src-tauri/src/utils/mod.rs | 2 | ||||
| -rw-r--r-- | src-tauri/src/utils/path.rs | 22 |
2 files changed, 12 insertions, 12 deletions
diff --git a/src-tauri/src/utils/mod.rs b/src-tauri/src/utils/mod.rs index 651d26b..c9ac368 100644 --- a/src-tauri/src/utils/mod.rs +++ b/src-tauri/src/utils/mod.rs @@ -1,5 +1,5 @@ -pub mod zip; pub mod path; +pub mod zip; // File system related utility functions #[allow(dead_code)] diff --git a/src-tauri/src/utils/path.rs b/src-tauri/src/utils/path.rs index deaebb5..1db6e5b 100644 --- a/src-tauri/src/utils/path.rs +++ b/src-tauri/src/utils/path.rs @@ -59,7 +59,7 @@ pub fn normalize_java_path(java_path: &str) -> Result<PathBuf, String> { } } } - + // If still not found after PATH search, return specific error if !path.exists() { return Err( @@ -80,7 +80,7 @@ pub fn normalize_java_path(java_path: &str) -> Result<PathBuf, String> { // Canonicalize and strip UNC prefix for clean path let canonical = std::fs::canonicalize(&path) .map_err(|e| format!("Failed to resolve Java path '{}': {}", path.display(), e))?; - + Ok(strip_unc_prefix(canonical)) } @@ -98,7 +98,7 @@ pub fn normalize_java_path(java_path: &str) -> Result<PathBuf, String> { } } } - + // If still not found after PATH search, return specific error if !path.exists() { return Err( @@ -119,7 +119,7 @@ pub fn normalize_java_path(java_path: &str) -> Result<PathBuf, String> { // Canonicalize to resolve symlinks and get absolute path let canonical = std::fs::canonicalize(&path) .map_err(|e| format!("Failed to resolve Java path '{}': {}", path.display(), e))?; - + Ok(strip_unc_prefix(canonical)) } @@ -196,23 +196,23 @@ mod tests { fn test_normalize_with_temp_file() { // Create a temporary file to test with an actual existing path let temp_dir = std::env::temp_dir(); - + #[cfg(target_os = "windows")] let temp_file = temp_dir.join("test_java_normalize.exe"); #[cfg(not(target_os = "windows"))] let temp_file = temp_dir.join("test_java_normalize"); - + // Create the file if let Ok(mut file) = fs::File::create(&temp_file) { let _ = file.write_all(b"#!/bin/sh\necho test"); drop(file); - + // Test normalization let result = normalize_java_path(temp_file.to_str().unwrap()); - + // Clean up let _ = fs::remove_file(&temp_file); - + // Verify result assert!(result.is_ok(), "Failed to normalize temp file path"); let normalized = result.unwrap(); @@ -227,12 +227,12 @@ mod tests { let unc_path = PathBuf::from(r"\\?\C:\Windows\System32\cmd.exe"); let stripped = strip_unc_prefix(unc_path); assert_eq!(stripped.to_string_lossy(), r"C:\Windows\System32\cmd.exe"); - + let normal_path = PathBuf::from(r"C:\Windows\System32\cmd.exe"); let unchanged = strip_unc_prefix(normal_path.clone()); assert_eq!(unchanged, normal_path); } - + #[cfg(not(target_os = "windows"))] { let path = PathBuf::from("/usr/bin/java"); |