Skip to content

Commit

Permalink
Add note to not close the console window.
Browse files Browse the repository at this point in the history
Use tabs instead of spaces to be consistent with python files.
  • Loading branch information
drojf committed Jul 10, 2019
1 parent 243a1a0 commit b83a916
Showing 1 changed file with 34 additions and 27 deletions.
61 changes: 34 additions & 27 deletions install_loader/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,38 @@ use tar::Archive;
use std::path::Path;

fn main() -> std::io::Result<()> {
// Extract all files to this subfolder (relative to the executable)
let sub_folder_path = Path::new("07th-mod_installer");

// During compilation, include the installer archive in .tar.xz format
//NOTE: The below file must be placed adjacent to this source file!
//The archive should not contain any subfolders - one will be created automatically
let archive_bytes = include_bytes!("install_data.tar.xz");

// Pipe from the XzDecoder (.xz handler) to the Archive (.tar handler), then extract all files.
println!("[07th-Mod Installer Loader] Please wait. Extracting to [{}]", sub_folder_path.display());
Archive::new(XzDecoder::new(&archive_bytes[..]))
.unpack(sub_folder_path).expect("Failed to extract tar archive");

// Start the installer, and wait for installer to finish
println!("[07th-Mod Installer Loader] Running installer");
let mut installer_handle= std::process::Command::new(
sub_folder_path.join(Path::new("python/python.exe"))
)
.current_dir(sub_folder_path)
.args(&["-E", "main.py"])
.spawn()
.expect("loader: failed to run batch file");
installer_handle.wait().expect("loader: failed to wait on install to finish");

println!("[07th-Mod Installer Loader] Exited");

Ok(())
// Tell the user not to close the terminal window
println!();
println!("------------------------------------------------------------");
println!("Do NOT close this window, unless you are finished installing");
println!("------------------------------------------------------------");
println!();

// Extract all files to this subfolder (relative to the executable)
let sub_folder_path = Path::new("07th-mod_installer");

// During compilation, include the installer archive in .tar.xz format
//NOTE: The below file must be placed adjacent to this source file!
//The archive should not contain any subfolders - one will be created automatically
let archive_bytes = include_bytes!("install_data.tar.xz");

// Pipe from the XzDecoder (.xz handler) to the Archive (.tar handler), then extract all files.
println!("[07th-Mod Installer Loader] Please wait. Extracting to [{}]", sub_folder_path.display());
Archive::new(XzDecoder::new(&archive_bytes[..]))
.unpack(sub_folder_path).expect("Failed to extract tar archive");

// Start the installer, and wait for installer to finish
println!("[07th-Mod Installer Loader] Running installer");
let mut installer_handle= std::process::Command::new(
sub_folder_path.join(Path::new("python/python.exe"))
)
.current_dir(sub_folder_path)
.args(&["-E", "main.py"])
.spawn()
.expect("loader: failed to run batch file");
installer_handle.wait().expect("loader: failed to wait on install to finish");

println!("[07th-Mod Installer Loader] Exited");

Ok(())
}

0 comments on commit b83a916

Please sign in to comment.