@@ -8,6 +8,20 @@ use inflector::Inflector;
8
8
use log:: * ;
9
9
use simplelog:: { TermLogger , TerminalMode , ColorChoice , Config } ;
10
10
11
+ fn try_absolute_exe_path ( exe_name : & str ) -> std:: ffi:: OsString
12
+ {
13
+ if let Ok ( maybe_path) = fs:: canonicalize ( format ! ( "{}.exe" , exe_name) )
14
+ {
15
+ if maybe_path. exists ( )
16
+ {
17
+ println ! ( "Successfully found abs path of [{}] at [{}]" , exe_name, maybe_path. to_string_lossy( ) ) ;
18
+ return maybe_path. into_os_string ( ) ;
19
+ }
20
+ }
21
+
22
+ return std:: ffi:: OsString :: from ( exe_name) ;
23
+ }
24
+
11
25
fn main ( ) -> ExitCode {
12
26
TermLogger :: init (
13
27
LevelFilter :: Trace ,
@@ -253,14 +267,14 @@ fn main() -> ExitCode {
253
267
let cwd = "output" . to_string ( ) ;
254
268
let files_to_archive = format ! ( "{}/sharedassets0.assets" , higu_ep_folder_name) ;
255
269
256
- let result_7za = pack_7zip ( "7za" , & archive, & cwd, & files_to_archive) ;
270
+ let result_7za = pack_7zip ( & try_absolute_exe_path ( "7za" ) , & archive, & cwd, & files_to_archive) ;
257
271
258
272
let status: std:: io:: Result < process:: ExitStatus > = match result_7za {
259
273
Ok ( ok) => Ok ( ok) ,
260
274
Err ( err) => match err. kind ( ) {
261
275
std:: io:: ErrorKind :: NotFound => {
262
276
println ! ( "Warning: '7za' not found - trying '7z' instead" ) ;
263
- pack_7zip ( "7z" , & archive, & cwd, & files_to_archive)
277
+ pack_7zip ( & try_absolute_exe_path ( "7z" ) , & archive, & cwd, & files_to_archive)
264
278
} ,
265
279
_ => Err ( err) ,
266
280
}
@@ -278,8 +292,8 @@ fn format_checksum(checksum: Option<&String>, sep: &str) -> String
278
292
return checksum. map_or ( "" . to_string ( ) , |c| format ! ( "{}{}" , sep, c) ) ;
279
293
}
280
294
281
- fn pack_7zip ( command : & str , archive : & String , cwd : & String , path : & String ) -> std:: io:: Result < process:: ExitStatus > {
282
- println ! ( "[7-Zip] Running {} in working directory: [{}] and path: [{}]..." , command, cwd, path) ;
295
+ fn pack_7zip < S : AsRef < std :: ffi :: OsStr > > ( command : & S , archive : & String , cwd : & String , path : & String ) -> std:: io:: Result < process:: ExitStatus > {
296
+ println ! ( "[7-Zip] Running {} in working directory: [{}] and path: [{}]..." , command. as_ref ( ) . to_string_lossy ( ) , cwd, path) ;
283
297
284
298
Command :: new ( command)
285
299
. current_dir ( cwd)
0 commit comments