tarfs

package
v0.0.0-...-33f67a6 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package tarfs is used to extract a tar file in memory and present it as a minimalistic read-only filesystem.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileInTar

type FileInTar struct {
	fs.File
	fs.FileInfo
	// contains filtered or unexported fields
}

FileInTar represents a combination of fs.File and fs.FileInfo interfaces.

func (*FileInTar) Close

func (f *FileInTar) Close() error

Close is a fs.File function.

func (*FileInTar) IsDir

func (f *FileInTar) IsDir() bool

IsDir returns true if the current file object represents a directory.

func (*FileInTar) ModTime

func (f *FileInTar) ModTime() time.Time

ModTime returns the last modified time of the file which corresponds to when the file was extracted from the tar archive.

func (*FileInTar) Mode

func (f *FileInTar) Mode() fs.FileMode

Mode returns the filemode.

func (*FileInTar) Name

func (f *FileInTar) Name() string

Name is a fs.FileInfo function. Returns the name of the file.

func (*FileInTar) NewOpenFile

func (f *FileInTar) NewOpenFile() *FileInTar

NewOpenFile creates a copy of the current file to represent a newly opened file.

func (*FileInTar) Read

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

Read is a fs.File function to read the file contents.

func (*FileInTar) Size

func (f *FileInTar) Size() int64

Size is a fs.FileInfo function. Returns the size of the data in memory.

func (*FileInTar) Stat

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

Stat is a fs.File function. Returns the object itself since it also implements the FileInfo interface.

func (*FileInTar) Sys

func (f *FileInTar) Sys() interface{}

Sys is intended to return the underlying datasource, but it is currently unimplemented.

type TarFS

type TarFS struct {
	fs.FS
	// contains filtered or unexported fields
}

TarFS is a minimal in-memory filesystem constructed from a tar archive. It is inefficient due to its copying of data for each open file request.

func NewTarFSFromBytes

func NewTarFSFromBytes(tarData []byte) (*TarFS, error)

NewTarFSFromBytes creates a new tar filesystem from the given byte data representing a tar archive.

func (*TarFS) Open

func (t *TarFS) Open(name string) (fs.File, error)

Open creates a new open file.

Jump to

Keyboard shortcuts

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