1#[cfg(unix)]
2macro_rules! lock_process {
3 ($lock_path:expr) => {
4 let lock_file = fs::File::create($lock_path)?;
5 let _lock = uvm_core::utils::lock_process_or_wait(&lock_file)?;
6 };
7}
8
9#[cfg(windows)]
10macro_rules! lock_process {
11 ($lock_path:expr) => {};
12}
13
14use log::*;
15use std::fs::DirBuilder;
16use std::fs::File;
17use std::path::{Path, PathBuf};
18use std::process::{Command, Stdio};
19use std::{fs, io};
20
21pub mod error;
22pub mod installer;
23mod loader;
24
25mod sys;
26
27use self::installer::*;
28use error::*;
29
30pub use self::loader::Loader;
31pub use self::sys::*;
32
33pub struct UnityModule;
34pub struct UnityEditor;
35
36pub trait InstallHandler {
37 fn install_handler(&self) -> Result<()>;
38
39 fn install(&self) -> Result<()> {
40 self.before_install()
41 .chain_err(|| "pre install step failed")?;
42 self.install_handler()
43 .map_err(|err| {
44 self.error_handler();
45 err
46 })
47 .chain_err(|| "installation failed")?;
48 self.after_install()
49 .chain_err(|| "post install step failed")
50 }
51
52 fn error_handler(&self) {}
53
54 fn before_install(&self) -> Result<()> {
55 Ok(())
56 }
57
58 fn after_install(&self) -> Result<()> {
59 Ok(())
60 }
61}