@@ -22,11 +22,12 @@ use crate::wide::{
2222 WideDisplay , WideString , is_dot_or_dot_dot, trim_wide_whitespace, wide_contains,
2323 wide_slice_from_ptr,
2424} ;
25+ use crate :: wide_path:: WidePathBuf ;
2526
2627/// Collect the filesystem and JVM options needed to launch HMCL.
2728pub struct JavaOptions {
28- pub workdir : WideString ,
29- pub jar_path : WideString ,
29+ pub workdir : WidePathBuf ,
30+ pub jar_path : WidePathBuf ,
3031 pub jvm_options : Option < WideString > ,
3132}
3233
@@ -46,7 +47,7 @@ impl JavaVersion {
4647 }
4748
4849 /// Read the PE version resource from a Java executable.
49- pub fn from_executable ( path : & WideString ) -> Self {
50+ pub fn from_executable ( path : & WidePathBuf ) -> Self {
5051 // Match the C++ launcher and read the executable's version resource
5152 // instead of spawning `java -version`.
5253 let size = unsafe { GetFileVersionInfoSizeW ( path. as_pcwstr ( ) , ptr:: null_mut ( ) ) } ;
@@ -65,9 +66,8 @@ impl JavaVersion {
6566 // version components in the same format as the upstream launcher.
6667 let mut info_ptr = ptr:: null_mut ( ) ;
6768 let mut info_len = 0u32 ;
68- let result = unsafe {
69- VerQueryValueW ( data. as_ptr ( ) . cast ( ) , w ! ( "\\ " ) , & mut info_ptr, & mut info_len)
70- } ;
69+ let result =
70+ unsafe { VerQueryValueW ( data. as_ptr ( ) . cast ( ) , w ! ( "\\ " ) , & mut info_ptr, & mut info_len) } ;
7171 if result == 0 || info_ptr. is_null ( ) || info_len < size_of :: < VS_FIXEDFILEINFO > ( ) as u32 {
7272 return Self :: invalid ( ) ;
7373 }
@@ -141,7 +141,7 @@ impl Display for JavaVersion {
141141/// Pair a Java executable path with the version discovered from its metadata.
142142pub struct JavaRuntime {
143143 pub version : JavaVersion ,
144- pub executable_path : WideString ,
144+ pub executable_path : WidePathBuf ,
145145}
146146
147147/// Own the set of discovered Java runtimes before launch selection.
@@ -158,7 +158,7 @@ impl JavaList {
158158 }
159159
160160 /// Add one candidate runtime when it exists, is unique, and is new enough.
161- pub fn try_add ( & mut self , java_executable : WideString ) -> bool {
161+ pub fn try_add ( & mut self , java_executable : WidePathBuf ) -> bool {
162162 if !is_regular_file ( & java_executable) {
163163 return false ;
164164 }
@@ -202,12 +202,13 @@ impl JavaList {
202202 /// Sort runtimes from lowest to highest version so callers can try the best
203203 /// match last-to-first.
204204 pub fn sort_by_version ( & mut self ) {
205- self . runtimes . sort_by ( |left, right| left. version . cmp ( & right. version ) ) ;
205+ self . runtimes
206+ . sort_by ( |left, right| left. version . cmp ( & right. version ) ) ;
206207 }
207208}
208209
209210/// Launch HMCL with a specific Java executable.
210- pub fn launch_jvm ( java_executable_path : & WideString , options : & JavaOptions ) -> bool {
211+ pub fn launch_jvm ( java_executable_path : & WidePathBuf , options : & JavaOptions ) -> bool {
211212 let mut command = WideString :: new ( ) ;
212213 if !command. push_char ( '"' )
213214 || !command. push_slice ( java_executable_path. as_slice ( ) )
@@ -279,7 +280,11 @@ pub fn launch_jvm(java_executable_path: &WideString, options: &JavaOptions) -> b
279280}
280281
281282/// Search one directory for subdirectories that look like Java homes.
282- pub fn search_java_in_dir ( result : & mut JavaList , basedir : & WideString , java_executable_name : & str ) {
283+ pub fn search_java_in_dir (
284+ result : & mut JavaList ,
285+ basedir : & WidePathBuf ,
286+ java_executable_name : & str ,
287+ ) {
283288 log_verbose_fmt ( format_args ! (
284289 "Searching in directory: {}" ,
285290 WideDisplay ( basedir. as_slice( ) )
@@ -325,7 +330,7 @@ pub fn search_java_in_dir(result: &mut JavaList, basedir: &WideString, java_exec
325330/// Probe the common vendor directories under Program Files.
326331pub fn search_java_in_program_files (
327332 result : & mut JavaList ,
328- program_files : & WideString ,
333+ program_files : & WidePathBuf ,
329334 java_executable_name : & str ,
330335) {
331336 // Search the same vendor folders as the upstream launcher.
@@ -441,7 +446,7 @@ pub fn search_java_in_registry(result: &mut JavaList, sub_key: PCWSTR, java_exec
441446 units -= 1 ;
442447 }
443448
444- if let Some ( mut executable) = WideString :: from_utf16 ( & java_home[ ..units] ) {
449+ if let Some ( mut executable) = WidePathBuf :: from_utf16 ( & java_home[ ..units] ) {
445450 if executable. push_path_component_str ( "bin" )
446451 && executable. push_path_component_str ( java_executable_name)
447452 {
@@ -469,7 +474,7 @@ pub fn search_java_in_path(result: &mut JavaList, path: &[u16], java_executable_
469474
470475 let entry = trim_wide_whitespace ( & path[ start..end] ) ;
471476 if !entry. is_empty ( ) {
472- if let Some ( mut java_executable) = WideString :: from_utf16 ( entry) {
477+ if let Some ( mut java_executable) = WidePathBuf :: from_utf16 ( entry) {
473478 if java_executable. push_path_component_str ( java_executable_name) {
474479 if wide_contains ( java_executable. as_slice ( ) , oracle_java) {
475480 // Keep the upstream exclusion for Oracle's shared shim
0 commit comments