wip
This commit is contained in:
@@ -6,6 +6,31 @@ use std::{collections::HashMap, fmt, path::Path};
|
||||
use bytes::Bytes;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Read version from version.ini file
|
||||
/// # Errors
|
||||
/// Returns error if file cannot be read or parsed
|
||||
pub fn read_version_from_ini(game_dir: &Path) -> eyre::Result<Option<String>> {
|
||||
let version_file = game_dir.join("version.ini");
|
||||
if !version_file.exists() {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let content = std::fs::read_to_string(&version_file)?;
|
||||
let version = content.trim().to_string();
|
||||
|
||||
// Validate format (YYYYMMDD)
|
||||
if version.len() == 8 && version.chars().all(|c| c.is_ascii_digit()) {
|
||||
Ok(Some(version))
|
||||
} else {
|
||||
tracing::warn!(
|
||||
"Invalid version format in {}: {}",
|
||||
version_file.display(),
|
||||
version
|
||||
);
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
/// A game
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
pub struct Game {
|
||||
@@ -31,6 +56,10 @@ pub struct Game {
|
||||
pub thumbnail: Option<Bytes>,
|
||||
/// only relevant for client (yeah... I know)
|
||||
pub installed: bool,
|
||||
/// ETI game version from version.ini (YYYYMMDD format) (server)
|
||||
pub eti_game_version: Option<String>,
|
||||
/// Local game version from version.ini (YYYYMMDD format)
|
||||
pub local_version: Option<String>,
|
||||
}
|
||||
|
||||
impl fmt::Debug for Game {
|
||||
|
||||
Reference in New Issue
Block a user