Guides
Inspect and read
Find out what an archive is and what is in it, and read a single file, without writing anything to disk. The same steps on peel, peel-core and the C library.
Which call answers which question
Every call on this page reads the archive and writes nothing. Each answers one question, and each is cheaper than extracting.
| Question | CLI | Rust | C |
|---|---|---|---|
| What format is this? | peel probe |
detect_format |
peel_probe |
| What is inside, with sizes and metadata? | peel inspect |
inspect_archive |
peel_inspect |
| What are the names? | peel list |
list_archive, list_archive_limited |
peel_list, peel_list_limited |
| What are one file’s bytes? | peel cat |
read_entry_bytes, read_entry_range,
OpenArchive |
peel_read_member,
peel_session_read_member_range |
| Is it intact? | peel test |
test_archive |
none: use the CLI or MCP test |
| What can Rind do with this format? | peel formats -j |
capabilities_for |
peel_formats |
The CLI examples run against a demo.zip made with
peel create demo.zip project, where project
holds README.md, src/main.rs and six chapter
files in docs/. Failures arrive as a stable kind, an exit
code on the CLI and a JSON object elsewhere: see errors.
Detect the format
Rind identifies a format from its content wherever the format has a
signature, so a ZIP named report.dat is still a ZIP.
peel probe reports the format, the entry count and the
volume layout, then says which operations Rind supports for that
format.
peel probe demo.zip
path: demo.zip
format: zip
entries: 11
multipart: false
volumes: demo.zip
ops: list=Supported extract=Supported password=Supported create=Supported
notes: ZIP/ZIP64; deflate, Deflate64, bzip2, LZMA, zstd, XZ; split sets name.zip.001… (not .z01 spanned); also backs epub/jar/apk/usdz/3mf/ooxml/odf/cbz, sketch and single-file iWork (pages/numbers/key)peel 1.4.0, recorded 2026-11-26.With -j, probe adds a
capabilities object (list,
extract_all, extract_selected,
create, password, multipart, each
supported, experimental,
conditional or unsupported), the capability
notes, and a session block with an id, the file’s size and
modification time, and a state. Use
capabilities.format as the stable format id, the same one
peel formats prints. The top-level format is a
display label, and its spelling varies: zip for ZIP,
SevenZ for 7z, TarZst for tar.zst.
A file Rind does not recognise fails with unsupported
(exit 7), and the detail names the first eight bytes it saw. A split set
such as photos.zip.001 is opened by that first name; the
bare photos.zip is not found.
use peel_core::{capabilities_for, detect_format};
use std::path::Path;
let format = detect_format(Path::new("upload.bin"))?; // Format::Zip, sniffed from content
let caps = capabilities_for(format); // support level per operation
println!("{:?}: list={:?} create={:?}", format, caps.list, caps.create);detect_bytes(&[u8]) does the same for a buffer you
already hold. In C, peel_probe returns a smaller object
than the CLI: entries, format,
multipart, path and volumes.
char *probe = peel_probe("upload.bin"); /* {"entries":11,"format":"Zip","multipart":false,...} */
puts(probe);
peel_string_free(probe);Look inside without extracting
peel inspect is the manifest. It extracts nothing. ZIP
and 7z answer from their index; a compressed tar has no index, so Rind
reads the stream through to list it.
peel inspect demo.zip
path: demo.zip
format: zip
zip_kind: Generic
entries: 11
uncompressed: 32550 bytes
compressed: 488 bytes
encrypted: false
size comp enc mode modified name
0 0 - 40755 1795688086 project/
47 49 - 100644 1795688086 project/README.md
0 0 - 40755 1795688086 project/docs/
5411 67 - 100644 1795688086 project/docs/chapter-1.md
5411 67 - 100644 1795688086 project/docs/chapter-2.md
5411 67 - 100644 1795688086 project/docs/chapter-3.md
5411 67 - 100644 1795688086 project/docs/chapter-4.md
… 4 more linespeel 1.4.0, recorded 2026-11-26.With -j the same data is one object:
{
"format": "zip",
"format_family": "zip",
"zip_kind": "generic",
"has_encrypted_entries": false,
"total_uncompressed_bytes": 32550,
"total_compressed_bytes": 488,
"diagnostics": [],
"entries": [
{ "name": "project/README.md", "kind": "file", "is_dir": false, "size": 47,
"compressed_size": 49, "compression_method": "Deflated", "crc32": 1176806996,
"mode": 33188, "modified_unix": 1795686830, "is_encrypted": false }
]
}| Level | Fields |
|---|---|
| Archive | format, format_family,
zip_kind, total_uncompressed_bytes,
total_compressed_bytes, has_encrypted_entries,
diagnostics, and comment (ZIP) or
is_solid (7z) when present |
| Entry, always | name, kind (file,
dir or symlink), is_dir,
size, is_encrypted |
| Entry, where the format records it | compressed_size, compression_method,
crc32, mode, modified_unix,
uid, gid, symlink_target |
A field the format does not carry is left out, not filled with a
default. ZIP carries the most. The tar family carries mode, owner,
modified time and link target but no CRC or compressed size, and
total_compressed_bytes is null for it. 7z and
the formats read through an index report names, types, sizes and, for
7z, modified time. peel formats -j states per format what
the manifest carries, in its metadata field.
modified_unix is Unix seconds.
.. is dropped from
inspect without a diagnostic. peel list shows
every name as stored, and peel test reports each unsafe one
as a failure. If the counts differ, that is why.
The safety model shows both on
one archive.
inspect has no password path that helps. ZIP names are
always readable, and inspect on a 7z with encrypted names
fails with password_required even when you pass one. Use
peel list with the password for those.
use peel_core::{inspect_archive, ResourceBudget};
use std::path::Path;
let summary = inspect_archive(Path::new("upload.zip"), &ResourceBudget::default())?;
println!("{} entries, {} bytes", summary.entry_count(), summary.total_uncompressed_bytes);
for e in summary.entries.iter().filter(|e| e.is_encrypted) {
println!("encrypted: {}", e.name);
}inspect_bytes takes a buffer instead of a path.
ArchiveSummary and its entries derive
serde::Serialize, so you can send them straight to a
client. In C, peel_inspect(path) returns the same manifest
as JSON, without diagnostics.
List names
peel list prints names. -l adds the type
and size, and -j prints an array of
{ "name", "is_dir", "size" } objects. The array also
carries modified_unix, mode, uid
and gid for formats whose reader fills them in, and nothing
for the rest.
peel list -l demo.zip 'project/docs/*.md'
size type name
5411 file project/docs/chapter-1.md
5411 file project/docs/chapter-2.md
5411 file project/docs/chapter-3.md
5411 file project/docs/chapter-4.md
5411 file project/docs/chapter-5.md
5411 file project/docs/chapter-6.md
6 entriespeel 1.4.0, recorded 2026-11-26.Patterns after the archive name filter the listing with the rules
extract uses: see selecting members. An
archive whose names are encrypted needs --password-stdin or
--password-fd here too.
The CLI has no cap on how many entries it prints. The library and the C library do:
use peel_core::list_archive_limited;
use std::path::Path;
let path = Path::new("demo.zip");
// At most 100 entries, and whether there were more. 0 means all.
let (entries, truncated) = list_archive_limited(path, 100)?;list_archive returns everything.
list_archive_with_password and
list_archive_limited_with_password take a password for
encrypted names, and list_archive_limited_cancellable takes
a cancel callback. A tar stream stops being decompressed once the cap is
passed, so a preview of a huge .tar.gz stays cheap. Other
formats read their index, which is already cheap, and are cut
afterwards. In C, peel_list_limited(path, 100) returns
{"entries":[…],"max_entries":100,"path":…,"truncated":false},
and peel_list returns the bare array. Installer packages
list the files inside their Payload and Scripts with
peel list --expand-payload, or
list_archive_expanded in Rust.
Read one file
peel cat writes one member to standard output without
touching the rest. The name must match one in the listing exactly: no
folder prefix is added, no glob is expanded, and a bare
README.md does not find project/README.md.
peel cat demo.zip project/README.mdThree limits keep a read bounded:
- Size cap. A member larger than
--max-bytes(64 MiB by default) fails withtoo_largeand exit 10, before its data is read where the format records a size. Raise the cap on purpose. - Window.
--offsetand--lengthread a byte range instead of the whole member. The range is at most 1 GiB and--lengthmust be above zero. - Kind. A symbolic link is not followed: it fails
with
unsupportedand names the target.
peel cat demo.zip project/README.md --offset 2 --length 4 -j
{
"binary": false,
"eof": false,
"length": 4,
"member": "project/README.md",
"offset": 2,
"text": "Demo",
"total_size": 47
}
$ peel cat demo.zip project/docs/chapter-1.md --max-bytes 100; echo "exit $?"
peel: project/docs/chapter-1.md is larger than the read limit of 100 bytes; raise it with --max-bytes
exit 10peel 1.4.0, recorded 2026-11-26.The window comes back with eof and
total_size. eof is true when the
member ended inside the window, so fewer bytes than asked is not an
error. total_size is null for formats that do
not state a size before the data, such as tar.zst. An offset past the
end returns zero bytes and exit 0.
Without a window, -j returns
{ "member", "size", "binary", "truncated", "text" }.
text is the content when it is valid UTF-8 and
null when it is not, with binary set. JSON
never carries raw bytes, so read a binary member from standard output
instead.
–offset are discarded. Memory stays bounded by the window,
but time does not. A RAR member is read through a scratch file and is
limited to 1 GiB.
In Rust, each call takes the exact name, an optional password, and a
cancelled callback that returns true to stop.
&|| false never cancels.
use peel_core::{read_entry_bytes, read_entry_range, EntryBytes, EntryRangeBytes};
use std::path::Path;
let path = Path::new("demo.zip");
// A whole member into memory, capped at 1 MiB (0 means no cap).
match read_entry_bytes(path, "project/README.md", 1 << 20, None, &|| false)? {
EntryBytes::Data { data } => println!("{} bytes", data.len()),
EntryBytes::Symlink { target } => println!("link to {target}"),
}
// Bytes [2, 6) of it.
if let EntryRangeBytes::Data { data, total_size } =
read_entry_range(path, "project/README.md", 2, 4, None, &|| false)?
{
println!("{:?} of {:?}", String::from_utf8_lossy(&data), total_size);
}extract_entry writes one member under a folder you name,
and read_entry_to_anon_file returns an open, unlinked
temporary file for handing the bytes to another process without a name
on disk.
Many reads from one archive
Opening an archive costs something on every call. When you read
several members, open it once. A ZIP keeps its central directory in
memory, so each later read skips the open and the scan. A multi-frame
.tar.zst or multi-block .tar.xz builds a
member table on its first read and then decodes only the units that hold
the member. Other formats keep the handle but still open the file for
each read. A session is safe to share between threads, and reads on one
session run one at a time. If the file changes after you opened it,
reads fail with an I/O error rather than answering from a stale
index.
use peel_core::{OpenArchive, SessionState};
use std::path::Path;
let path = Path::new("photos.cbz");
let archive = OpenArchive::open(path, None)?; // a damaged ZIP fails here, not on first read
assert_eq!(archive.state(), SessionState::Open);
let page = archive.read_entry_bytes("page-001.jpg", 32 << 20, &|| false)?;
let head = archive.read_entry_range("page-002.jpg", 0, 4096, &|| false)?;
archive.close();The CLI has no session: each peel cat opens the archive.
The MCP server has
open_archive and close_archive, and
read_member takes offset, length
and a session id. In C, the session is a PeelSession.
#include <stdio.h>
#include "peel.h"
int main(int argc, char **argv) {
if (argc < 3) { fprintf(stderr, "usage: inspect ARCHIVE MEMBER\n"); return 2; }
char *err = NULL;
PeelSession *s = peel_session_open(argv[1], NULL, &err); /* NULL, or a password */
if (!s) { fprintf(stderr, "%s\n", err); peel_string_free(err); return 1; }
size_t len = 0;
uint64_t total = 0;
/* offset 2, length 4. total is UINT64_MAX when the format does not say. */
unsigned char *buf = peel_session_read_member_range(s, argv[2], 2, 4, NULL, &len, &total, &err);
if (buf) {
printf("%zu of %llu bytes: %.*s\n", len, (unsigned long long)total, (int)len, buf);
peel_bytes_free(buf, len);
} else {
fprintf(stderr, "%s\n", err); /* {"error":"not_found",...} */
peel_string_free(err);
}
peel_session_close(s);
return buf ? 0 : 1;
}peel_session_read_member reads a whole member with a
max_bytes cap, where 0 means no cap.
peel_read_member does the same without a session, and
peel_read_member_fd returns an open descriptor to an
unlinked file. A symlink is unsupported, and a member name
containing .. or a leading / is refused. An
empty member returns a non-NULL pointer and a length of 0. The C library page covers ownership of every
buffer.
Check that it is intact
peel test reads every entry to the end and reports which
fail. It writes nothing.
peel test demo.zip
OK Zip 11 entries, 8 verified, 0 unchecked demo.zip
$ peel test demo.tar.zst
OK TarZst 8 entries, 8 verified, 0 unchecked demo.tar.zst
$ peel test hostile.zip; echo "exit $?"
BAD Zip 3 entries, 1 verified, 0 unchecked hostile.zip
FAIL ../escape.txt: invalid entry name: ../escape.txt
FAIL /etc/absolute.txt: invalid entry name: /etc/absolute.txt
peel: 2 of 3 entries failed
exit 1peel 1.4.0, recorded 2026-11-26.In 1.4.0 the summary counts verified entries, read to
the end without error, and unchecked ones, which the format
has no per-entry reader for. A verified ZIP or RAR entry also matched
its data checksum; a plain tar entry has no checksum to match, so
verified there means only readable. The next release splits the count to
say which is which.
With -j the report is one object:
{
"entries": 11,
"failures": [],
"format": "Zip",
"ok": true,
"unchecked": 0,
"verified": 8
}A failure is { "name", "error" }. A report with any
failure has ok: false. The command then exits 1, and with
-j the report is followed by
{"error":"other",…} on standard error. A wrong or missing
password exits 4 or 3 like every other command.
use peel_core::test_archive;
use std::path::Path;
let path = Path::new("demo.zip");
let report = test_archive(path, None, &|| false)?; // TestReport
if !report.ok() {
for f in &report.failures { eprintln!("{}: {}", f.name, f.error); }
}
println!("{} of {} verified", report.verified, report.entries);A checksum finds corruption. It does not say who made the file or
whether it is safe to run. The C library has no test call, so run
peel test or the MCP test tool where you need
one.
Capabilities by format
peel formats -j prints one object per format with
format, family, probe,
list, extract_all,
extract_selected, create,
password, multipart, notes,
password_notes and metadata. Branch on it when
a host handles many formats. In Rust it is
capabilities_for(Format) and
all_format_capabilities(), in C
peel_formats(), and the full table is on the formats page.
formats
-j marks create as supported for a few formats that
peel create refuses, including brotli, lz4, lzip and
compress. The list of what it writes is on
Create archives.
Next: extract safely, once you know what you are about to unpack.
void peel_bytes_free(unsigned char *ptr, size_t len) Free a buffer returned by peel_read_member or a session read.char *peel_probe(const char *archive_path) Detect the format, the volumes and the entry count, cheaply.void peel_session_close(PeelSession *session) Close and free a session; NULL is ignored.PeelSession *peel_session_open(const char *archive_path, const char *password, char **error_json) Open an archive once and keep its index, for many reads. NULL with an error JSON on failure.unsigned char *peel_session_read_member_range(const PeelSession *session, const char *member, uint64_t offset, uint64_t length, const PeelCancelToken *token, size_t *out_len, uint64_t *out_total, char **error_json) Read a byte range of one member through an open session.void peel_string_free(char *s) Free a JSON string returned by any peel_* call.peel cat Print one member’s contents to standard output without unpacking the rest.capabilities_for(Format) FormatCapabilities: support level for list, extract, create, password and multipart, plus notes.detect_format(&Path) Format: sniffed from content, not the extension.inspect_archive(&Path, &ResourceBudget) ArchiveSummary: format, format_family, zip_kind, entries: Vec<ArchiveEntryInfo>, total_uncompressed_bytes, total_compressed_bytes, has_encrypted_entries, comment, is_solid.read_entry_bytes(archive, name, max_bytes, password, &cancelled) Read one entry into memory.read_entry_range(archive, name, offset, length, password, &cancelled) Read bytes [offset, offset + length) of one entry.test_archive Entry-by-entry integrity check.