The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Archive::SCS - SCS archive controller

SYNOPSIS

  my $scs = Archive::SCS->new;
  $scs->mount("$path/base.scs");
  $scs->mount("$path/def.scs");

  my @contents = sort $scs->list_dirs, $scs->list_files;

  say $scs->read_entry('def/env_data.sii');

DESCRIPTION

Handles the union file system used by SCS archive files. Allows mounting of multiple files and performs lookups in all of them using the SCS hash algorithm.

These modules exist primarily to support the scs_archive command-line tool included in this distribution.

METHODS

formats

  @formats = $scs->formats;

Returns the list of currently active formats. See set_formats().

list_dirs

  @directories = $scs->list_dirs;

Returns an ordered list of all directory paths in currently mounted archives. The root directory, represented by an empty string, is currently omitted from the list.

Paths are returned without a leading / because that's the way they are stored internally. This is subject to change, but the output of list_dirs() will always be good to use as path for read_entry().

list_files

  @files = $scs->list_files;

Returns an ordered list of all file paths in currently mounted archives.

Paths are returned without a leading / because that's the way they are stored internally. This is subject to change, but the output of list_files() will always be good to use as path for read_entry().

list_orphans

  @orphan_hashes = $scs->list_orphans;

Returns a list of hash values for orphans in currently mounted archives.

Some file formats allow files (or subdirs) without a directory entry. These files may be accessed directly using their hash value. This software refers to such files as orphans. For example, the following orphans are known to exist in 1.49.3.14:

  05c075dc23d8d177 # in core.scs, 'def/achievements.sii'
  0eeaffbe65995414 # in base.scs + core.scs, 'ui/desktop_demo.sii'
  0fb3a3294f8ac99c # in base_cfg.scs
  2a794836b65afe88 # in base.scs
  34f7048e2d3b04b6 # in core.scs, 'def/online_economy_data.sii'
  507dcc5fb3fb6443 # in core.scs, 'def/online_data.sii'
  83a9902d7733b94d # in core.scs, 'def/mod_manager_data.sii'
  88a1194cb25b253c # in core.scs, 'ui/desktop_standalone_demo.sii'
  c09356068ea66aac # in core.scs, 'def/world/building_scheme_core_scs.sii'
  d9d3d2a218c69f3d # in base.scs
  e773fb1407c8468d # in core.scs, 'def/world/building_model_core_scs.sii'

mount

  $archive = $scs->mount($pathname);
  $archive = $scs->mount($mountable);

Adds the given SCS archive to the currently mounted archives. Returns an Archive::SCS::Mountable object. If a file system path is given as argument, the object will be created by attempting to load the given archive with the currently active formats. See set_formats().

new

  $scs = Archive::SCS->new;

Creates a new Archive::SCS object.

read_entry

  $data = $scs->read_entry($pathname);
  $data = $scs->read_entry($hash);

Returns the contents of the given entry. Directories will be returned as Archive::SCS::DirIndex objects and HashFS v2 texture objects as Archive::SCS::TObj.

The argument may be the pathname within the archive or its hash value, hex-encoded in network byte order as a 16-byte scalar PV. Paths are expected without a leading / because that's the way they are stored internally. This is subject to change, but the output of list_files() will always be good to use as path for read_entry().

set_formats

  $scs = $scs->set_formats(qw[ HashFS Zip ]);

Sets the list of currently active formats. All formats must be in the Archive::SCS namespace. By default, the list includes all formats implemented in this distribution, which currently are the following:

unmount

  $archive = $scs->unmount($pathname);
  $archive = $scs->mount($mountable);

Removes the given SCS archive from currently mounted archives. Returns the archive's Archive::SCS::Mountable object.

SEE ALSO

AUTHOR

nautofon

COPYRIGHT

This software is copyright (c) 2024 by nautofon.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

Includes CityHash 1.0.3, Copyright (c) 2011 Google, Inc. (MIT license)