v/vlib/archive/tar
gechandesu 75417c55fc
Some checks are pending
Graphics CI / gg-regressions (push) Waiting to run
vlib modules CI / build-module-docs (push) Waiting to run
Shy and PV CI / v-compiles-puzzle-vibes (push) Waiting to run
sdl CI / v-compiles-sdl-examples (push) Waiting to run
Time CI / time-linux (push) Waiting to run
Time CI / time-macos (push) Waiting to run
Time CI / time-windows (push) Waiting to run
toml CI / toml-module-pass-external-test-suites (push) Waiting to run
Tools CI / tools-linux (clang) (push) Waiting to run
Tools CI / tools-linux (gcc) (push) Waiting to run
Tools CI / tools-linux (tcc) (push) Waiting to run
Tools CI / tools-macos (clang) (push) Waiting to run
Tools CI / tools-windows (gcc) (push) Waiting to run
Tools CI / tools-windows (msvc) (push) Waiting to run
Tools CI / tools-windows (tcc) (push) Waiting to run
Tools CI / tools-docker-ubuntu-musl (push) Waiting to run
vab CI / vab-compiles-v-examples (push) Waiting to run
vab CI / v-compiles-os-android (push) Waiting to run
archive.tar: fix type in new_compressor fn name (#25006)
2025-07-30 19:49:00 +03:00
..
testdata
reader.v archive.tar: fix type in new_compressor fn name (#25006) 2025-07-30 19:49:00 +03:00
reader_test.v archive.tar: fix type in new_compressor fn name (#25006) 2025-07-30 19:49:00 +03:00
README.md
tar.v
untar.v

Description

tar is a module to access tar archives.

Tape archives (tar) are a file format for storing a sequence of files that can be read and written as streams. This module covers the reading of the basic sections of archives produced by GNU tools like Linux command tar -xvf but in memory instead modifing the filesystem. Parses directories, files, and file's content and manage paths longer than 100 chars.

Read Efficiency

An entire tar file can be read in memory or by chunks. Keeps in memory a single decompressed chunk of 32 KB at a time and also keeps in memory a single tar block of 512 bytes at a time. Convert paths to strings until needed and the user reader implementation can stop early the reading process.

Read Example

The tar blocks are parsed and some fields are passed to Reader implemented methods.

import os
import archive.tar

fn main() {
	os.chdir(@VMODROOT) or {}
	path := 'archive/tar/testdata/life.tar.gz'
	reader := tar.new_debug_reader()
	tar.read_tar_gz_file(path, reader)!
}

Look also in examples folder the tar_gz_reader.v program.