pub struct ModpkgExtractor<'modpkg, TSource: Read + Seek> { /* private fields */ }Expand description
Extractor for ModPkg archives.
This struct provides functionality to extract chunks from a ModPkg archive to a specified directory, organized by layers.
Implementations§
Source§impl<'modpkg, TSource: Read + Seek> ModpkgExtractor<'modpkg, TSource>
impl<'modpkg, TSource: Read + Seek> ModpkgExtractor<'modpkg, TSource>
Sourcepub fn new(modpkg: &'modpkg mut Modpkg<TSource>) -> Self
pub fn new(modpkg: &'modpkg mut Modpkg<TSource>) -> Self
Create a new extractor for the given ModPkg.
Sourcepub fn extract_all(
&mut self,
output_dir: impl AsRef<Path>,
) -> Result<(), ModpkgError>
pub fn extract_all( &mut self, output_dir: impl AsRef<Path>, ) -> Result<(), ModpkgError>
Extract all chunks from the ModPkg to the specified output directory.
Content chunks are organized by layer, with each layer having its own
subdirectory, in layer-name order. Meta chunks belong to no layer and are
written to the output root under the names a mod project uses for them
(see extract_meta).
This is a package unpacked to look at, not a mod project: a project keeps
its layers under content/ and is read from a mod.config.json that no
chunk holds. Use ltk_mod_project’s ModpkgImporter to write one of
those, or call extract_layer and
extract_meta with the two directories yourself.
Sourcepub fn layer_names(&self) -> Vec<String>
pub fn layer_names(&self) -> Vec<String>
The package’s layer names, in the order extract_all
walks them.
Sorted, because the header’s layer table is hashed and two extractions of one package must not report their layers in two different orders. A layer the package declares but holds no chunk for is still listed.
Sourcepub fn extract_layer(
&mut self,
layer: &str,
output_dir: impl AsRef<Path>,
) -> Result<(), ModpkgError>
pub fn extract_layer( &mut self, layer: &str, output_dir: impl AsRef<Path>, ) -> Result<(), ModpkgError>
Extract one layer’s chunks into output_dir/{layer}/.
A chunk’s stored path is relative to the WAD it belongs to, so it is
written under a directory of that WAD’s name: {layer}/{wad}/{path}.
That is the layout a mod project holds its content in, and the one
ModpkgBuilder reads WAD membership
back out of, so extract -> pack keeps every chunk in the WAD it came
from. A chunk belonging to no WAD is written at {layer}/{path}, and a
chunk several WADs share is written once under each of them.
A layer the package does not hold writes nothing rather than failing: a project may declare a layer whose content it has yet to add.
Sourcepub fn extract_meta(
&mut self,
output_dir: impl AsRef<Path>,
) -> Result<(), ModpkgError>
pub fn extract_meta( &mut self, output_dir: impl AsRef<Path>, ) -> Result<(), ModpkgError>
Write the meta chunks that have a project-level file form to output_dir.
That is the readme, the license text and the thumbnail, under the names
a mod project keeps them at its root, and the hashtables, under
hashes/. Chunks without such a form (the metadata chunk, which is
msgpack rather than a project file) are skipped rather than dumped
under _meta_/; read it with Modpkg::load_metadata instead.
Sourcepub fn extract_chunk(
&mut self,
chunk: &ModpkgChunk,
output_dir: impl AsRef<Path>,
) -> Result<PathBuf, ModpkgError>
pub fn extract_chunk( &mut self, chunk: &ModpkgChunk, output_dir: impl AsRef<Path>, ) -> Result<PathBuf, ModpkgError>
Extract a specific chunk to the specified directory.
Sourcepub fn extract_chunk_by_path(
&mut self,
path: &str,
layer: &str,
output_dir: impl AsRef<Path>,
) -> Result<PathBuf, ModpkgError>
pub fn extract_chunk_by_path( &mut self, path: &str, layer: &str, output_dir: impl AsRef<Path>, ) -> Result<PathBuf, ModpkgError>
Extract a specific chunk by its path and layer name.