Skip to main content

Module session

Module session 

Source
Expand description

Opening an archive for extraction and working out whether it fits. Shared by the command line and the GUI, so the two never disagree.

Structs§

SpacePlan
Whether an extraction fits, in the numbers a person needs to decide.

Enums§

Output
Where an extraction goes, and who said so. A half-extracted archive’s progress files lie next to it, where whoever supplied the archive could have put them, so a resume follows them only into a folder this computer recorded starting that extraction in (see check_output).
State

Functions§

begin
Commits to a fresh extraction: saves the archive’s tail and writes the journal. From here on the archive may be truncated, unless keep_archive is set, in which case nothing ever changes it. Files in the way (see existing) are refused unless replace is given; then the run moves them aside before it extracts anything, and once it is complete deletes them or puts back the ones the choices keep.
case_sensitive
Whether names that differ only in case can both exist in dir, as far as HatchZip knows.
check_output
The journal lies next to the archive, where anyone who supplied the archive could have put one, so it is used only for an extraction this computer recorded starting into that folder (see [crate::chosen]). A resume deletes what it finds at the paths of the entries left and cuts the archive to what the journal says, so a planted journal could otherwise destroy the archive and replace the person’s own files in the folder it names. A folder given now must also be the journal’s, and one HatchZip worked out (Output::Computed) vouches for nothing: a planted journal can name it as easily as the app does. Without the record the journal is never followed, whatever its format says: a planted one can claim to come from a release that kept no record.
check_sfv
Checks the archive’s volumes against an .sfv file next to it, if present.
clear_uncommitted
Before continuing a crashed run, deletes what it wrote for batches it never committed.
default_output
game.zip, game.7z.001, game.tar.gz, game.part1.rar and game.z01 all extract into game, next to them.
display_name
game.zip, or game.7z.001 (+4 more parts) for a split archive.
existing
The files and links already in out at paths the archive extracts to, relative to out. A fresh extraction may only replace them when asked to; see begin. When there are any, what would keep them from being replaced is refused here, before a front end asks.
keeps_archive
Whether the extraction of a half-extracted archive keeps it, given what the person asked for now. The journal decides: an extraction that keeps the archive goes on keeping it, and one that has already removed part of it can’t start keeping it.
locate
The first volume of the archive and where its journal lives. Paths are made absolute so a resume works from any directory.
nested_offer
The archive a finished run offers to extract for path, one of the files in written, the files it wrote: the first volume of its set, so a set is offered once whichever volume is asked about. None unless path and that first volume are archives by name and signature, and every volume of the set is in written (volumes_written). A native split ZIP is found by its .z01, whose split marker no other check names.
open
writable is false for anything that only looks, so it works on read-only media and never takes the lock. For a fresh extraction the output folder may already hold other files, but no folder where the archive has a file or the other way round; files the archive would replace are listed by existing. password only matters for encrypted archives; see open_encrypted for the ask-and-retry loop front ends want. What opening reads is counted in reads, which a front end can show from another thread: a compressed tar is read in full here.
open_encrypted
Opens an archive that may be encrypted. ask is called whenever a password is needed or the last one was wrong, and returns None to give up. Archives with a password are proven with Job::check_password before this returns, so nothing is deleted on a wrong guess. Returns the state and the password that worked.
open_encrypted_noting
open_encrypted, calling slow with a file and its size before a password check that decodes all of it (see Job::slow_password_check), so a front end can say it may take a while.
plan
The space plan for extracting job into out, keeping the archive or not. For a half-extracted archive, keep_archive must be what its journal says; see keeps_archive.
retarget
Moves a fresh extraction opened writable by open to another folder, checking it as open checks the one it was given.
single_root
Whether everything in the archive sits under one name at its top, one folder or a single file. “Extract here” puts such an archive next to itself; anything else would scatter loose files, so it gets a folder.
volumes_written
Whether every volume of the set whose first volume is primary that exists on disk is in written. A set that is not split has one volume.