Import std.compress.seven_zip
std.compress.seven_zip
Reading 7z archives.
7z's archives, read over liblzma: SevenZip.Read gives a SevenZipReader of a 7z's entries. Its folders' coders can be stored, LZMA, LZMA2, Delta, and the branch filters for x86, PowerPC, IA-64, ARM, ARM Thumb, ARM64, SPARC, and RISC-V, in a chain, as 7-Zip writes them by default. Others, like BCJ2, PPMd, BZip2, and AES's encryption, read as an IOError. A solid folder is decoded whole, once for the files read from it in turn. Writing 7z isn't std's.
Examples
// A 7z of a folder, partial, and its one.txt, as 7-Zip writes it.
Local bytesHex = "377abcaf271c0004fa9fa01c0b0000000000000064000000000000002b62ef43"
bytesHex += "66697273742066696c650a0104060001090b00070b01000101000c0b0a01df30"
bytesHex += "dbf400080d0109000005020e01400f0180113100700061007200740069006100"
bytesHex += "6c002f006f006e0065002e007400780074000000700061007200740069006100"
bytesHex += "6c0000001507004000100000000000"
Local bytes = Hex.Decode(bytesHex) ?? []
Local archive = Try SevenZip.Read(bytes)
Expect(archive.Count == 2 && archive.Contains("partial/one.txt"))
Expect(archive.Find("partial")?.Kind == ArchiveEntryKind.FOLDER)
Local text = Try archive.Read("partial/one.txt")
Expect(text == "first file\n".Bytes)std/compress/seven_zip.fb
Types
SevenZip
struct
Public Struct SevenZip
What reads 7z archives, in its Static Methods.
std/compress/seven_zip.fb, line 46
-
A reader of the 7z in
data, which it copies, or an IOError when thedataisn't a 7z, ends early, or its header uses what isn't supported.
SevenZipReader
class
Public Class SevenZipReader
A 7z's entries, which Read gives the bytes of, from a copy of the 7z's bytes.
std/compress/seven_zip.fb, line 57
-
Its entries, in the order the 7z has them.
-
How many entries it has.
-
The entry named
name, the last of them when there are several, or Null when there's none. -
Whether it has an entry named
name. -
The bytes of the entry named
name, the last of them when there are several, or Null when there's none, as ReadAt gives them. -
The bytes of the entry at
index, which are none for a folder or a link, or an IOError when they're broken, or use a coder that isn't supported. Panics when theindexis out of range.
Report an issue with this page or with FutureBlitz on GitHub.