Darktide Mod Manager #39

Merged
lucas merged 91 commits from feat/dtmm into master 2023-03-01 22:27:42 +01:00
3 changed files with 40 additions and 17 deletions
Showing only changes of commit 0cf2908904 - Show all commits

12
Cargo.lock generated
View file

@ -56,6 +56,17 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46016233fc1bb55c23b856fe556b7db6ccd05119a0a392e04f0b3b7c79058f16" checksum = "46016233fc1bb55c23b856fe556b7db6ccd05119a0a392e04f0b3b7c79058f16"
[[package]]
name = "async-recursion"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b015a331cc64ebd1774ba119538573603427eaace0a1950c423ab971f903796"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "atk" name = "atk"
version = "0.16.0" version = "0.16.0"
@ -2007,6 +2018,7 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
name = "sdk" name = "sdk"
version = "0.2.0" version = "0.2.0"
dependencies = [ dependencies = [
"async-recursion",
"bitflags", "bitflags",
"byteorder", "byteorder",
"color-eyre", "color-eyre",

View file

@ -23,3 +23,4 @@ tokio-stream = { version = "0.1.11", features = ["fs", "io-util"] }
tracing = { version = "0.1.37", features = ["async-await"] } tracing = { version = "0.1.37", features = ["async-await"] }
tracing-error = "0.2.0" tracing-error = "0.2.0"
luajit2-sys = "0.0.2" luajit2-sys = "0.0.2"
async-recursion = "1.0.2"

View file

@ -4,6 +4,7 @@ use std::ops::{Deref, DerefMut};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::str::FromStr; use std::str::FromStr;
use async_recursion::async_recursion;
use color_eyre::eyre::{self, Context}; use color_eyre::eyre::{self, Context};
use color_eyre::Result; use color_eyre::Result;
use tokio::fs; use tokio::fs;
@ -13,14 +14,15 @@ use crate::bundle::file::{BundleFileType, UserFile};
use crate::murmur::{HashGroup, Murmur64}; use crate::murmur::{HashGroup, Murmur64};
#[tracing::instrument] #[tracing::instrument]
#[async_recursion]
async fn resolve_wildcard<P1, P2>( async fn resolve_wildcard<P1, P2>(
wildcard: P1, wildcard: P1,
root: P2, root: P2,
t: Option<BundleFileType>, t: Option<BundleFileType>,
) -> Result<Vec<PathBuf>> ) -> Result<Vec<PathBuf>>
where where
P1: AsRef<Path> + std::fmt::Debug, P1: AsRef<Path> + std::fmt::Debug + std::marker::Send,
P2: AsRef<Path> + std::fmt::Debug, P2: AsRef<Path> + std::fmt::Debug + std::marker::Send + std::marker::Copy,
{ {
let wildcard = wildcard.as_ref(); let wildcard = wildcard.as_ref();
@ -56,6 +58,12 @@ where
path.to_path_buf() path.to_path_buf()
}; };
let meta = entry.metadata().await?;
if meta.is_dir() {
let wildcard = file_path.join("*");
let inner_paths = resolve_wildcard(wildcard, root, t).await?;
paths.extend_from_slice(&inner_paths);
} else {
// Skip file if there is a desired extension `t`, but the file's // Skip file if there is a desired extension `t`, but the file's
// extension name doesn't match // extension name doesn't match
if t.is_some() { if t.is_some() {
@ -65,7 +73,7 @@ where
.and_then(|ext| BundleFileType::from_str(ext).ok()); .and_then(|ext| BundleFileType::from_str(ext).ok());
if ext != t { if ext != t {
tracing::debug!( tracing::warn!(
"Skipping wildcard result with invalid extension: {}", "Skipping wildcard result with invalid extension: {}",
file_path.display(), file_path.display(),
); );
@ -73,8 +81,10 @@ where
} }
} }
tracing::debug!("Found file {}", file_path.display());
paths.push(file_path); paths.push(file_path);
} }
}
Ok(paths) Ok(paths)
} }