Skip to content

Commit

Permalink
Update repak
Browse files Browse the repository at this point in the history
  • Loading branch information
trumank committed Dec 17, 2023
1 parent bbc9838 commit 7c5d5bf
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 26 deletions.
57 changes: 51 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ edition = "2021"
anyhow = { version = "1.0.75", features = ["backtrace"] }
patternsleuth = { git = "https://github.com/trumank/patternsleuth" }
steamlocate = "2.0.0-alpha.0"
repak = { git = "https://github.com/trumank/repak" }

[package]
name = "mint"
Expand Down Expand Up @@ -76,11 +77,8 @@ uasset_utils = { git = "https://github.com/trumank/uasset_utils" }
unreal_asset = { git = "https://github.com/trumank/unrealmodding", branch = "patches" }
url = "2.5.0"
zip = { version = "0.6.6", default-features = false, features = ["aes-crypto", "deflate", "time"] }
repak = { workspace = true, features = ["oodle", "oodle_loader"] }

[target.'cfg(windows)'.dependencies]
repak = { git = "https://github.com/trumank/repak", features = ["oodle"] }
[target.'cfg(not(windows))'.dependencies]
repak = { git = "https://github.com/trumank/repak" }
[target.'cfg(target_env = "msvc")'.dependencies]
hook = { path = "hook", artifact = "cdylib", optional = true, target = "x86_64-pc-windows-msvc"}
[target.'cfg(not(target_env = "msvc"))'.dependencies]
Expand Down
1 change: 1 addition & 0 deletions mint_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ edition.workspace = true
[dependencies]
anyhow.workspace = true
steamlocate.workspace = true
repak.workspace = true
33 changes: 20 additions & 13 deletions src/integrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,12 @@ pub fn integrate<P: AsRef<Path>>(
kind: IntegrationErrKind::Generic(e),
})?;
let mut fsd_pak_reader = BufReader::new(fsd_pak_file);
let fsd_pak = repak::PakReader::new_any(&mut fsd_pak_reader).map_err(|e| IntegrationErr {
mod_ctxt: None,
kind: IntegrationErrKind::Repak(e),
})?;
let fsd_pak = repak::PakBuilder::new()
.reader(&mut fsd_pak_reader)
.map_err(|e| IntegrationErr {
mod_ctxt: None,
kind: IntegrationErrKind::Repak(e),
})?;

#[derive(Debug, Default)]
struct Dir<'a> {
Expand Down Expand Up @@ -309,7 +311,7 @@ pub fn integrate<P: AsRef<Path>>(
})?;
}

let mut mod_pak = repak::PakWriter::new(
let mut mod_pak = repak::PakBuilder::new().writer(
BufWriter::new(
OpenOptions::new()
.write(true)
Expand Down Expand Up @@ -362,10 +364,13 @@ pub fn integrate<P: AsRef<Path>>(
kind: IntegrationErrKind::Generic(e),
}
})?;
let pak = repak::PakReader::new_any(&mut buf).map_err(|e| IntegrationErr {
mod_ctxt: Some(mod_info.clone()),
kind: IntegrationErrKind::Repak(e),
})?;
let pak = repak::PakBuilder::new()
.oodle(repak::oodle_loader::decompress)
.reader(&mut buf)
.map_err(|e| IntegrationErr {
mod_ctxt: Some(mod_info.clone()),
kind: IntegrationErrKind::Repak(e),
})?;

let mount = Path::new(pak.mount_point());

Expand Down Expand Up @@ -466,10 +471,12 @@ pub fn integrate<P: AsRef<Path>>(
patch_deferred(modding_tab_path, patch_modding_tab_item)?;

let mut int_pak_reader = Cursor::new(include_bytes!("../assets/integration.pak"));
let int_pak = repak::PakReader::new_any(&mut int_pak_reader).map_err(|e| IntegrationErr {
mod_ctxt: None,
kind: IntegrationErrKind::Repak(e),
})?;
let int_pak = repak::PakBuilder::new()
.reader(&mut int_pak_reader)
.map_err(|e| IntegrationErr {
mod_ctxt: None,
kind: IntegrationErrKind::Repak(e),
})?;

let mount = Path::new(int_pak.mount_point());
let files = int_pak.files();
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub fn write_file<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, data: C) -> Result<()

pub fn is_drg_pak<P: AsRef<Path>>(path: P) -> Result<()> {
let mut reader = std::io::BufReader::new(open_file(path)?);
let pak = repak::PakReader::new_any(&mut reader)?;
let pak = repak::PakBuilder::new().reader(&mut reader)?;
pak.get("FSD/FSD.uproject", &mut reader)?;
Ok(())
}
Expand Down
4 changes: 3 additions & 1 deletion src/mod_lints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ impl LintCtxt {
}

let mut first_pak_read_seek = individual_pak_readers.remove(0);
let pak_reader = repak::PakReader::new_any(&mut first_pak_read_seek)?;
let pak_reader = repak::PakBuilder::new()
.oodle(repak::oodle_loader::decompress)
.reader(&mut first_pak_read_seek)?;
f(mod_spec.clone(), &mut first_pak_read_seek, &pak_reader)?
}

Expand Down
2 changes: 1 addition & 1 deletion src/mod_lints/unmodified_game_assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl Lint for UnmodifiedGameAssetsLint {
// Adapted from
// <https://github.com/trumank/repak/blob/a006d9ed6f021687a87b8b2ff9d66083d019824c/repak_cli/src/main.rs#L217>.
let mut reader = BufReader::new(open_file(game_pak_path)?);
let pak = repak::PakReader::new_any(&mut reader)?;
let pak = repak::PakBuilder::new().reader(&mut reader)?;

let mount_point = PathBuf::from(pak.mount_point());

Expand Down

0 comments on commit 7c5d5bf

Please sign in to comment.