use std::{ io, path::{Path, PathBuf}, }; use serde::{Deserialize, Serialize}; use crate::{types::link::Link, utils::walk_all_files}; /// Available game #[derive(Debug, Clone, Deserialize, Serialize)] pub struct Game { path: PathBuf, } impl Game { pub fn export_links(&self) -> Result, io::Error> { let links: Vec = walk_all_files(&self.path)? .map(|entry| { Link::new( entry.path(), entry .path() .strip_prefix(&self.path) .expect("Can't transform path back to relative. Should not happen."), ) }) .collect(); Ok(links) } pub fn install_location(&self) -> &Path { &self.path } }