libs updated
libs updated
This commit is contained in:
21
src/main.rs
21
src/main.rs
@@ -6,14 +6,17 @@ extern crate ini;
|
||||
extern crate exitcode;
|
||||
|
||||
use std::env;
|
||||
use std::ffi::OsStr;
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
use sysinfo::{System, SystemExt};
|
||||
use sysinfo::System;
|
||||
|
||||
mod mod_locales;
|
||||
mod mod_fs;
|
||||
mod mods;
|
||||
|
||||
use crate::mods::mod_fs::*;
|
||||
use crate::mods::mod_locales::*;
|
||||
|
||||
/// Rule description structure
|
||||
struct Rule {
|
||||
@@ -75,7 +78,7 @@ fn check_process(process_name: String) -> bool {
|
||||
|
||||
sys.refresh_all();
|
||||
|
||||
for _process in sys.processes_by_exact_name(&process_name) {
|
||||
for _process in sys.processes_by_exact_name(OsStr::new(&process_name)) {
|
||||
result = true;
|
||||
}
|
||||
|
||||
@@ -137,7 +140,7 @@ fn debug_log(text: String) {
|
||||
/// execute("gedit".to_string());
|
||||
/// ```
|
||||
fn execute(command: String) {
|
||||
let locale = mod_locales::Locale::new();
|
||||
let locale = Locale::new();
|
||||
|
||||
debug_log(format!("{} {}", locale.t().execute, command));
|
||||
|
||||
@@ -172,7 +175,7 @@ fn execute(command: String) {
|
||||
/// print_help(args.clone());
|
||||
/// ```
|
||||
fn print_help(args: Vec<String>) {
|
||||
let locale = mod_locales::Locale::new();
|
||||
let locale = Locale::new();
|
||||
|
||||
if cfg!(windows) {
|
||||
if args.len() > 1 && (args[1].to_string() == "/help".to_string() || args[1].to_string() == "/?".to_string()) {
|
||||
@@ -219,13 +222,13 @@ fn print_help(args: Vec<String>) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let locale = mod_locales::Locale::new();
|
||||
let locale = Locale::new();
|
||||
|
||||
let args: Vec<String> = env::args().collect();
|
||||
|
||||
print_help(args.clone());
|
||||
|
||||
let mut config_file = mod_fs::get_exe_path();
|
||||
let mut config_file = get_exe_path();
|
||||
|
||||
if cfg!(windows) {
|
||||
config_file = format!("{}\\cai-watchdog.ini", config_file);
|
||||
@@ -450,7 +453,7 @@ fn main() {
|
||||
|
||||
let mut just_started_prc = true;
|
||||
|
||||
let locale = mod_locales::Locale::new();
|
||||
let locale = Locale::new();
|
||||
|
||||
loop {
|
||||
for i in 0..tasks_prc.len() {
|
||||
|
||||
2
src/mods/mod.rs
Normal file
2
src/mods/mod.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
pub mod mod_fs;
|
||||
pub mod mod_locales;
|
||||
@@ -8,12 +8,19 @@ use std::path::PathBuf;
|
||||
///
|
||||
/// Return executable path or . if can't determine it
|
||||
pub fn get_exe_path() -> String {
|
||||
let mut dir;
|
||||
let exe_path: String;
|
||||
|
||||
match env::current_exe() {
|
||||
Ok(full_name) => {
|
||||
let mut dir = PathBuf::from(full_name);
|
||||
dir = PathBuf::from(full_name);
|
||||
dir.pop();
|
||||
dir.into_os_string().into_string().unwrap_or(".".to_string())
|
||||
exe_path = dir.clone().into_os_string().into_string().unwrap();
|
||||
},
|
||||
Err(_e) => {
|
||||
exe_path = ".".to_string();
|
||||
},
|
||||
Err(_) => ".".to_string(),
|
||||
}
|
||||
|
||||
return exe_path;
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
use std::borrow::Borrow;
|
||||
use std::path::Path;
|
||||
|
||||
use crate::mod_fs;
|
||||
use crate::mods::mod_fs;
|
||||
use sys_locale::get_locale;
|
||||
|
||||
pub struct Lang {
|
||||
Reference in New Issue
Block a user