diff options
| author | Filip Wandzio <contact@philw.dev> | 2026-02-25 16:10:23 +0100 |
|---|---|---|
| committer | Filip Wandzio <contact@philw.dev> | 2026-02-25 16:10:23 +0100 |
| commit | f7b4b643ebc52a4d72d90d9adbdddc9aa0721e4a (patch) | |
| tree | c96432be342b02bc0409e5b78b6b5d54afcc7cd6 /src/util/fs.rs | |
| parent | 2e10b0713f5369f489d2ababd70108cc359c5d2d (diff) | |
| download | dml-f7b4b643ebc52a4d72d90d9adbdddc9aa0721e4a.tar.gz dml-f7b4b643ebc52a4d72d90d9adbdddc9aa0721e4a.zip | |
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
Diffstat (limited to 'src/util/fs.rs')
| -rw-r--r-- | src/util/fs.rs | 26 |
1 files changed, 25 insertions, 1 deletions
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; | |||
| 4 | 4 | ||
| 5 | use tokio::fs::remove_file; | 5 | use tokio::fs::remove_file; |
| 6 | 6 | ||
| 7 | use crate::errors::McError; | 7 | use crate::{ |
| 8 | errors::McError, | ||
| 9 | minecraft::manifests::{Library, Rule}, | ||
| 10 | }; | ||
| 8 | 11 | ||
| 9 | pub async fn remove_if_exists(path: &Path) -> Result<(), McError> { | 12 | pub async fn remove_if_exists(path: &Path) -> Result<(), McError> { |
| 10 | if path.exists() { | 13 | if path.exists() { |
| @@ -12,3 +15,24 @@ pub async fn remove_if_exists(path: &Path) -> Result<(), McError> { | |||
| 12 | } | 15 | } |
| 13 | Ok(()) | 16 | Ok(()) |
| 14 | } | 17 | } |
| 18 | |||
| 19 | pub fn library_allowed(lib: &Library) -> bool { | ||
| 20 | let rules: &Vec<Rule> = match &lib.rules { | ||
| 21 | | Some(r) => r, | ||
| 22 | | None => return true, | ||
| 23 | }; | ||
| 24 | |||
| 25 | let mut allowed: bool = false; | ||
| 26 | |||
| 27 | for rule in rules { | ||
| 28 | let os_match: bool = match &rule.os { | ||
| 29 | | Some(os) => os.name == "linux", | ||
| 30 | | None => true, | ||
| 31 | }; | ||
| 32 | if os_match { | ||
| 33 | allowed = rule.action == "allow"; | ||
| 34 | } | ||
| 35 | } | ||
| 36 | |||
| 37 | allowed | ||
| 38 | } | ||
