added link_plugin_files to linker
This commit is contained in:
@@ -4,6 +4,8 @@ use std::{
|
|||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::fomod::FileTypeEnum;
|
||||||
|
|
||||||
pub struct Linker {
|
pub struct Linker {
|
||||||
target: PathBuf,
|
target: PathBuf,
|
||||||
}
|
}
|
||||||
@@ -85,6 +87,35 @@ impl Linker {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn link_plugin_files(
|
||||||
|
&self,
|
||||||
|
entries: &[FileTypeEnum],
|
||||||
|
mod_dir: &Path,
|
||||||
|
) -> Result<(), LinkerError> {
|
||||||
|
let mut sorted_entries = entries.to_owned();
|
||||||
|
sorted_entries.sort_by_cached_key(|e| match e {
|
||||||
|
FileTypeEnum::File(file_type) => file_type.priority.unwrap_or(0),
|
||||||
|
FileTypeEnum::Folder(file_type) => file_type.priority.unwrap_or(0),
|
||||||
|
});
|
||||||
|
|
||||||
|
for entry in sorted_entries {
|
||||||
|
match entry {
|
||||||
|
FileTypeEnum::File(file) => {
|
||||||
|
let from = mod_dir.join(file.source);
|
||||||
|
let to = Path::new("Data").join(file.destination.unwrap_or("".to_owned()));
|
||||||
|
self.link_file(&from, &to)?;
|
||||||
|
}
|
||||||
|
FileTypeEnum::Folder(folder) => {
|
||||||
|
let from = mod_dir.join(folder.source);
|
||||||
|
let to = Path::new("Data").join(folder.destination.unwrap_or("".to_owned()));
|
||||||
|
self.link_recursive(&from, &to)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|||||||
Reference in New Issue
Block a user