libs updated
libs updated
This commit is contained in:
parent
b4672e4057
commit
74cbb0bb5f
929
Cargo.lock
generated
929
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -12,10 +12,9 @@ chrono = "0.4.31"
|
|||||||
# Sync
|
# Sync
|
||||||
#reqwest = { version = "0.11", features = ["blocking"] }
|
#reqwest = { version = "0.11", features = ["blocking"] }
|
||||||
# Async
|
# Async
|
||||||
reqwest = "0.11.22"
|
reqwest = "0.12.12"
|
||||||
tokio = { version = "1.34.0", features = ["full"] }
|
tokio = { version = "1.34.0", features = ["full"] }
|
||||||
ini = "1.3.0"
|
ini = "1.3.0"
|
||||||
exitcode = "1.1.2"
|
exitcode = "1.1.2"
|
||||||
hashmap = "0.0.1"
|
sysinfo = "0.33.1"
|
||||||
sysinfo = "0.29.10"
|
|
||||||
sys-locale = "0.3.1"
|
sys-locale = "0.3.1"
|
||||||
|
|||||||
21
src/main.rs
21
src/main.rs
@ -6,14 +6,17 @@ extern crate ini;
|
|||||||
extern crate exitcode;
|
extern crate exitcode;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use std::ffi::OsStr;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use sysinfo::{System, SystemExt};
|
use sysinfo::System;
|
||||||
|
|
||||||
mod mod_locales;
|
mod mods;
|
||||||
mod mod_fs;
|
|
||||||
|
use crate::mods::mod_fs::*;
|
||||||
|
use crate::mods::mod_locales::*;
|
||||||
|
|
||||||
/// Rule description structure
|
/// Rule description structure
|
||||||
struct Rule {
|
struct Rule {
|
||||||
@ -75,7 +78,7 @@ fn check_process(process_name: String) -> bool {
|
|||||||
|
|
||||||
sys.refresh_all();
|
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;
|
result = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +140,7 @@ fn debug_log(text: String) {
|
|||||||
/// execute("gedit".to_string());
|
/// execute("gedit".to_string());
|
||||||
/// ```
|
/// ```
|
||||||
fn execute(command: String) {
|
fn execute(command: String) {
|
||||||
let locale = mod_locales::Locale::new();
|
let locale = Locale::new();
|
||||||
|
|
||||||
debug_log(format!("{} {}", locale.t().execute, command));
|
debug_log(format!("{} {}", locale.t().execute, command));
|
||||||
|
|
||||||
@ -172,7 +175,7 @@ fn execute(command: String) {
|
|||||||
/// print_help(args.clone());
|
/// print_help(args.clone());
|
||||||
/// ```
|
/// ```
|
||||||
fn print_help(args: Vec<String>) {
|
fn print_help(args: Vec<String>) {
|
||||||
let locale = mod_locales::Locale::new();
|
let locale = Locale::new();
|
||||||
|
|
||||||
if cfg!(windows) {
|
if cfg!(windows) {
|
||||||
if args.len() > 1 && (args[1].to_string() == "/help".to_string() || args[1].to_string() == "/?".to_string()) {
|
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() {
|
fn main() {
|
||||||
let locale = mod_locales::Locale::new();
|
let locale = Locale::new();
|
||||||
|
|
||||||
let args: Vec<String> = env::args().collect();
|
let args: Vec<String> = env::args().collect();
|
||||||
|
|
||||||
print_help(args.clone());
|
print_help(args.clone());
|
||||||
|
|
||||||
let mut config_file = mod_fs::get_exe_path();
|
let mut config_file = get_exe_path();
|
||||||
|
|
||||||
if cfg!(windows) {
|
if cfg!(windows) {
|
||||||
config_file = format!("{}\\cai-watchdog.ini", config_file);
|
config_file = format!("{}\\cai-watchdog.ini", config_file);
|
||||||
@ -450,7 +453,7 @@ fn main() {
|
|||||||
|
|
||||||
let mut just_started_prc = true;
|
let mut just_started_prc = true;
|
||||||
|
|
||||||
let locale = mod_locales::Locale::new();
|
let locale = Locale::new();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
for i in 0..tasks_prc.len() {
|
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
|
/// Return executable path or . if can't determine it
|
||||||
pub fn get_exe_path() -> String {
|
pub fn get_exe_path() -> String {
|
||||||
|
let mut dir;
|
||||||
|
let exe_path: String;
|
||||||
|
|
||||||
match env::current_exe() {
|
match env::current_exe() {
|
||||||
Ok(full_name) => {
|
Ok(full_name) => {
|
||||||
let mut dir = PathBuf::from(full_name);
|
dir = PathBuf::from(full_name);
|
||||||
dir.pop();
|
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::borrow::Borrow;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use crate::mod_fs;
|
use crate::mods::mod_fs;
|
||||||
use sys_locale::get_locale;
|
use sys_locale::get_locale;
|
||||||
|
|
||||||
pub struct Lang {
|
pub struct Lang {
|
||||||
Loading…
x
Reference in New Issue
Block a user