airbreather / StepperUpper

Some tools for making STEP happen.
MIT License
9 stars 2 forks source link

Extract BSA Files #12

Closed airbreather closed 7 years ago

airbreather commented 7 years ago

Use Case

Some power users prefer managing a mod's content themselves, instead of leaving it packaged up inside BSA archives. This allows such a user to, for instance, "hide" a file from a later mod that would otherwise win a conflict against a file of the same name as a file in an earlier mod.

Many mods that include BSA files also provide "loose files" versions for the benefit of such users, but not all.

Proposed Solution

BSAopt apparently has a reasonably useful command-line interface, so this might be easy.

If it's not as easy as that makes it sound, we can P/Invoke libbsa to get the job done.

And if all else fails, the (Skyrim) archive file format isn't nearly as complicated as the mod file format, especially if I'm just reading from it and so I don't have to worry about name hashes / sorting / name rules / compression, so it's at least possible.

Edit: BSAopt capitalization

airbreather commented 7 years ago

This should be doable now using RunProcess. Need to confirm, though.

airbreather commented 7 years ago

Hmm... we could also just write something like this and do it during a Finalize-like thing:

<ExtractBSAContent BSAOptPath="BSAOpt/BSAOpt.exe" ParentFolder="ModOrganizer/mods" />

It would just find all the .bsa files and extract their content in-place, then delete (or just hide) the original .bsa files themselves.

tstavrianos commented 7 years ago

What about using something like this: Sharp.BSA.BA2. Should allow you to use it for SSE as well (if you decide to go down that route later on.

airbreather commented 7 years ago

@tstavrianos thanks, BSAUtil looks a lot like code that was kicking around in my head when I was thinking about implementing a reader myself. Hopefully I'll just be able to get BSAopt to work.

FWIW, I've started working on SR:LE, and BSA extraction seems to be required for a few parts of that to work, so this does need to happen at some point.

Edit: BSAopt capitalization

airbreather commented 7 years ago

Well 5a59196 seems to work for SR:LE. I still have some testing to do to make sure it's identical to what BSAopt does in the cases that matter, but at a preliminary glance, the things I've looked at seem appropriate.

The official HRDLC02.bsa seems to have some placeholder.txt files that aren't valid zlib, so I'd like to either figure out how BSAopt manages to get around that, or just continue semi-skipping them.

airbreather commented 7 years ago

All the BSA files we extract in the SR:LE setup match the output of BSAopt, identically.

Good enough for me.

airbreather commented 7 years ago

I've logged an issue on the BSAopt project in the hopes that I can use that to stop maintaining my own version of the BSA code.