tarfs

package
v0.0.0-...-4dc34af Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package tarfs provides a read-only file system interface to tar archives.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DirEntry

type DirEntry struct {
	// contains filtered or unexported fields
}

DirEntry represents a directory entry in a tar archive.

func (DirEntry) Info

func (d DirEntry) Info() (fs.FileInfo, error)

Info implements fs.DirEntry.

func (DirEntry) IsDir

func (d DirEntry) IsDir() bool

IsDir implements fs.DirEntry.

func (DirEntry) Name

func (d DirEntry) Name() string

Name implements fs.DirEntry.

func (DirEntry) Type

func (d DirEntry) Type() fs.FileMode

Type implements fs.DirEntry.

type File

type File struct {
	// contains filtered or unexported fields
}

File represents a file in a tar archive.

func (*File) Close

func (f *File) Close() error

Close implements fs.File.

func (*File) FileInfo

func (f *File) FileInfo() fs.FileInfo

FileInfo returns the fs.FileInfo for the tar entry.

func (*File) IsDir

func (f *File) IsDir() bool

IsDir reports whether the tar entry is a directory.

func (*File) Name

func (f *File) Name() string

Name returns the name of the tar entry.

func (*File) Read

func (f *File) Read(p []byte) (int, error)

Read implements io.Reader. For directories, returns an error.

func (*File) ReadDir

func (f *File) ReadDir(n int) ([]fs.DirEntry, error)

ReadDir implements fs.ReadDirFile for directories.

func (*File) Stat

func (f *File) Stat() (fs.FileInfo, error)

Stat implements fs.File.

type TarError

type TarError struct {
	Archive, Name string
	Err, Cause    error
}

TarError represents an error that occurred while accessing a file in a tar archive.

func (*TarError) Error

func (e *TarError) Error() string

func (*TarError) Unwrap

func (e *TarError) Unwrap() []error

type TarFile

type TarFile struct {
	// contains filtered or unexported fields
}

TarFile represents a read-only file system backed by a tar archive. It will lazily buffer the contents of the tar archive as files are accessed.

Entries are accessed in order and cached as they are read, so random access may be inefficient.

func FromReader

func FromReader(name string, r io.Reader) *TarFile

FromReader creates a new TarFile from an io.Reader containing a tar archive.

FromReader takes ownership of r, reading from it as needed. If r is an io.ReadCloser it will be closed when either [r.Read] returns an error or [Close] is called.

If r is not an io.ReadCloser, it will be wrapped in io.NopCloser.

func Open

func Open(name string) (*TarFile, error)

Open opens a tar file as a read-only file system.

func OpenFS

func OpenFS(fs ihfs.FS, name string) (*TarFile, error)

OpenFS opens a tar file from fs as a read-only file system.

func (*TarFile) Close

func (t *TarFile) Close() error

Close closes the underlying tar archive.

func (*TarFile) Name

func (t *TarFile) Name() string

Name returns the name of the tar file backing this file system.

func (*TarFile) Open

func (t *TarFile) Open(name string) (ihfs.File, error)

Open implements ihfs.FS.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL