From b930622d5101b33f84c6d657898afe37cd797f37 Mon Sep 17 00:00:00 2001 From: Elkien3 Date: Sat, 19 Jan 2019 12:19:43 -0600 Subject: [PATCH] make better way to make relative paths absolute --- src/main.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1d2b202..1956deb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -68,12 +68,16 @@ fn try_main() -> Result<(), String> { for argument in std::env::args() { if argument.contains("minetest") && !argument.contains("mumble-wrapper") && std::path::Path::new(&argument).exists() { minetest_command = std::path::PathBuf::from(argument); + + // Relative paths with Command are undefined. + if minetest_command.is_relative() { + let mut absolute_path = std::env::current_dir().unwrap(); + absolute_path.push(minetest_command); + minetest_command = absolute_path; + } } } - // Canonicalize the path because relative paths with Command are undefined. - minetest_command = minetest_command.canonicalize().unwrap_or_default(); - if !minetest_command.exists() { // If the program args didn't provide a valid path, try the search paths. for path in search_paths.iter_mut() { @@ -99,9 +103,6 @@ fn try_main() -> Result<(), String> { } } - // Canonicalize the path because relative paths with Command are undefined. - minetest_command = minetest_command.canonicalize().unwrap_or_default(); - // Whoops we couldn't find it... if !minetest_command.exists() { return Err("Unable to find Minetest executable! Try passing its path to the command-line...".to_owned());