#![allow(dead_code)] use std::path::Path; use tokio::fs::remove_file; use crate::{ errors::McError, minecraft::manifests::{Library, Rule}, }; pub async fn remove_if_exists(path: &Path) -> Result<(), McError> { if path.exists() { remove_file(path).await?; } 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 }