move get_game_exe_path to be a method on SystemInfo
This commit is contained in:
@@ -1,14 +1,5 @@
|
|||||||
use crate::{
|
use crate::{gui::settings::BlockMethod, util::system_info::SystemInfo};
|
||||||
gui::settings::BlockMethod,
|
use std::{error::Error, path::PathBuf};
|
||||||
util::{
|
|
||||||
consts::game::{EXE_ENHANCED, EXE_LEGACY},
|
|
||||||
system_info::SystemInfo,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
use std::{
|
|
||||||
error::Error,
|
|
||||||
path::{Path, PathBuf},
|
|
||||||
};
|
|
||||||
use windows::{
|
use windows::{
|
||||||
Win32::{
|
Win32::{
|
||||||
NetworkManagement::WindowsFirewall::{
|
NetworkManagement::WindowsFirewall::{
|
||||||
@@ -159,12 +150,3 @@ impl GameNetworking {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_game_exe_path(system_info: &mut SystemInfo) -> Option<&Path> {
|
|
||||||
system_info.refresh();
|
|
||||||
system_info
|
|
||||||
.processes()
|
|
||||||
.iter()
|
|
||||||
.find(|p| p.name() == EXE_ENHANCED || p.name() == EXE_LEGACY)
|
|
||||||
.and_then(|p| p.exe())
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ use windows::{
|
|||||||
core::PWSTR,
|
core::PWSTR,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::util::consts::game::{EXE_ENHANCED, EXE_LEGACY};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Process {
|
pub struct Process {
|
||||||
pid: u32,
|
pid: u32,
|
||||||
@@ -80,6 +82,14 @@ impl SystemInfo {
|
|||||||
self.processes = processes;
|
self.processes = processes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_game_exe_path(&mut self) -> Option<&Path> {
|
||||||
|
self.refresh();
|
||||||
|
self.processes()
|
||||||
|
.iter()
|
||||||
|
.find(|p| p.name() == EXE_ENHANCED || p.name() == EXE_LEGACY)
|
||||||
|
.and_then(|p| p.exe())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn processes(&self) -> &[Process] {
|
pub fn processes(&self) -> &[Process] {
|
||||||
&self.processes
|
&self.processes
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user