feat: phase 2

Newfound motivation
This commit is contained in:
2025-02-23 05:12:21 +01:00
parent fdf3679fbe
commit a29bce2227
36 changed files with 1367 additions and 615 deletions

50
rust/src/liner.rs Normal file
View File

@ -0,0 +1,50 @@
use tokio::task::JoinSet;
use anyhow::Result;
use tokio::fs;
use crate::util;
use crate::profile::Profile;
pub async fn line_up(p: &Profile) -> Result<()> {
let dir_out = util::profile_dir(&p);
log::info!("Preparing {}", dir_out.to_string_lossy());
let mut futures = JoinSet::new();
if dir_out.join("BepInEx").exists() {
futures.spawn(fs::remove_dir_all(dir_out.join("BepInEx")));
}
if dir_out.join("option").exists() {
futures.spawn(fs::remove_dir_all(dir_out.join("option")));
}
while let Some(_) = futures.join_next().await {}
fs::create_dir_all(dir_out.join("option")).await?;
log::debug!("--");
for m in &p.mods {
log::debug!("{}", m.0);
let dir_out = util::profile_dir(&p);
let (namespace, name) = m.0.split_at(m.0.find("-").expect("Invalid mod definition"));
let bpx = util::pkg_dir_of(namespace, &name[1..])
.join("app")
.join("BepInEx");
if bpx.exists() {
util::copy_recursive(&bpx, &dir_out.join("BepInEx"))?;
}
let opt = util::pkg_dir_of(namespace, &name[1..]).join("option");
if opt.exists() {
let x = opt.read_dir().unwrap().next().unwrap()?;
if x.metadata()?.is_dir() {
fs::symlink(&x.path(), &dir_out.join("option").join(x.file_name())).await?;
}
}
}
log::debug!("--");
for opt in p.path.join("option").read_dir()? {
let opt = opt?;
fs::symlink(&opt.path(), &dir_out.join("option").join(opt.file_name())).await?;
}
Ok(())
}