From f7b4b643ebc52a4d72d90d9adbdddc9aa0721e4a Mon Sep 17 00:00:00 2001 From: Filip Wandzio Date: Wed, 25 Feb 2026 16:10:23 +0100 Subject: Feat: Refactor core download logic with concurrency and async features Implement basic unit testing Implement automatic java executable switching based on game version Split loader module into smaller modules Implement basic documentation --- src/util/fs.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/util/fs.rs') diff --git a/src/util/fs.rs b/src/util/fs.rs index 8ecd0d0..b1e9152 100644 --- a/src/util/fs.rs +++ b/src/util/fs.rs @@ -4,7 +4,10 @@ use std::path::Path; use tokio::fs::remove_file; -use crate::errors::McError; +use crate::{ + errors::McError, + minecraft::manifests::{Library, Rule}, +}; pub async fn remove_if_exists(path: &Path) -> Result<(), McError> { if path.exists() { @@ -12,3 +15,24 @@ pub async fn remove_if_exists(path: &Path) -> Result<(), McError> { } Ok(()) } + +pub fn library_allowed(lib: &Library) -> bool { + let rules: &Vec = match &lib.rules { + | Some(r) => r, + | None => return true, + }; + + let mut allowed: bool = false; + + for rule in rules { + let os_match: bool = match &rule.os { + | Some(os) => os.name == "linux", + | None => true, + }; + if os_match { + allowed = rule.action == "allow"; + } + } + + allowed +} -- cgit v1.2.3