move get_game_exe_path to be a method on SystemInfo
This commit is contained in:
@@ -1,14 +1,5 @@
|
||||
use crate::{
|
||||
gui::settings::BlockMethod,
|
||||
util::{
|
||||
consts::game::{EXE_ENHANCED, EXE_LEGACY},
|
||||
system_info::SystemInfo,
|
||||
},
|
||||
};
|
||||
use std::{
|
||||
error::Error,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
use crate::{gui::settings::BlockMethod, util::system_info::SystemInfo};
|
||||
use std::{error::Error, path::PathBuf};
|
||||
use windows::{
|
||||
Win32::{
|
||||
NetworkManagement::WindowsFirewall::{
|
||||
@@ -159,12 +150,3 @@ impl GameNetworking {
|
||||
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,
|
||||
};
|
||||
|
||||
use crate::util::consts::game::{EXE_ENHANCED, EXE_LEGACY};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Process {
|
||||
pid: u32,
|
||||
@@ -80,6 +82,14 @@ impl SystemInfo {
|
||||
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] {
|
||||
&self.processes
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user