Compare commits
3 Commits
f4f3dc261b
...
b1c7d96f29
| Author | SHA1 | Date | |
|---|---|---|---|
|
b1c7d96f29
|
|||
|
984246b263
|
|||
|
0e97a77288
|
@@ -67,4 +67,8 @@ impl<'a> ConflictSolver<'a> {
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
pub fn export_files(&self) -> Vec<(&ModFile, &Mod)> {
|
||||
self.files.values().copied().collect()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::{
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use crate::fomod::FileTypeEnum;
|
||||
use crate::{Mod, ModFile, fomod::FileTypeEnum};
|
||||
|
||||
pub struct Linker {
|
||||
target: PathBuf,
|
||||
@@ -49,6 +49,12 @@ impl Linker {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn link_mod_file(&self, file: &ModFile, from_mod: &Mod) -> Result<(), LinkerError> {
|
||||
let src = from_mod.source.join(&file.source);
|
||||
|
||||
self.link_file(&src, &file.dest)
|
||||
}
|
||||
|
||||
pub fn link_plugin_files(
|
||||
&self,
|
||||
entries: &[FileTypeEnum],
|
||||
|
||||
35
src/main.rs
35
src/main.rs
@@ -5,7 +5,9 @@ use std::{
|
||||
};
|
||||
|
||||
use crate::{
|
||||
conflict_resolver::ConflictSolver,
|
||||
fomod::{FileType, FileTypeEnum},
|
||||
linker::Linker,
|
||||
mod_config_installer::FomodInstaller,
|
||||
};
|
||||
|
||||
@@ -95,14 +97,43 @@ struct Mod {
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
const XML_PATH: &str = "./data/xml/ineed.xml";
|
||||
|
||||
let xml = fs::read_to_string(XML_PATH)?;
|
||||
|
||||
let loaded_mod = Mod {
|
||||
name: "INeed".to_owned(),
|
||||
source: Path::new("./data/mods/iNeed v1").to_owned(),
|
||||
priority: 0,
|
||||
};
|
||||
|
||||
let config: fomod::Config = quick_xml::de::from_str(&xml)?;
|
||||
|
||||
let installer = FomodInstaller::new(config, vec![], install_prompt::prompt);
|
||||
|
||||
dbg!(installer.run());
|
||||
let files = installer.run();
|
||||
|
||||
let converted_files: Vec<_> = files
|
||||
.iter()
|
||||
.flat_map(|f| ModFile::from_installer(f.clone(), &loaded_mod).unwrap())
|
||||
.collect();
|
||||
|
||||
let mut solver = ConflictSolver::new();
|
||||
|
||||
for file in &converted_files {
|
||||
if let Some(conflict) = solver.add_file(file, &loaded_mod) {
|
||||
println!("Conflict deteced: {:?}", conflict);
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
let files_to_link = solver.export_files();
|
||||
|
||||
let linker = Linker::new(Path::new("./data/target"), Path::new("./data/install"));
|
||||
|
||||
linker.link_install_to_target()?;
|
||||
|
||||
for (file, from_mod) in files_to_link {
|
||||
linker.link_mod_file(file, from_mod)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user