the great refactor

This commit is contained in:
2026-03-04 22:50:37 +01:00
parent b6efa0a818
commit c81178567a
15 changed files with 519 additions and 448 deletions

33
src/types/game.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::{
io,
path::{Path, PathBuf},
};
use serde::Deserialize;
use crate::{types::link::Link, utils::walk_all_files};
/// Available game
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct Game {
install_location: PathBuf,
}
impl Game {
pub fn export_links(&self) -> Result<Vec<Link>, io::Error> {
let links: Vec<Link> = walk_all_files(&self.install_location)?
.map(|entry| {
Link::new(
entry.path(),
entry.path().strip_prefix(&self.install_location).unwrap(),
)
})
.collect();
Ok(links)
}
pub fn install_location(&self) -> &Path {
&self.install_location
}
}