Documentation
¶
Index ¶
- Constants
- Variables
- func AppendTarRecoveryRecord(filename string, pct int) error
- func Compress(inputFilePath, outputFilePath string) error
- func DetectFormat(r io.ReaderAt) (uint16, error)
- func Extract(inputFilePath, outputFilePath string) error
- func GetStandardIndexPath(archivePath string) (string, error)
- func IndexArchive(archivePath, indexPath string) error
- func LocateShadowStream(ra io.ReaderAt, fileSize int64, method uint16) (int64, int64, error)
- func NewReader(r io.Reader) *tar.Reader
- func NewWriter(w io.Writer) *tar.Writer
- func RegisterCompressor(method uint16, comp Compressor)
- func RegisterDecompressor(method uint16, dcomp Decompressor)
- func WriteMagicFooter(w io.Writer, method uint16, shadowStart, shadowSize int64) error
- type AppendMode
- type Archiver
- type ArchiverOption
- func WithArchiverEmbeddedIndex(b bool) ArchiverOption
- func WithArchiverIndex(path string) ArchiverOption
- func WithArchiverLevel(level int) ArchiverOption
- func WithArchiverLock(b bool) ArchiverOption
- func WithArchiverMethod(method uint16) ArchiverOption
- func WithArchiverPassword(p string) ArchiverOption
- func WithArchiverPathMapping(m map[string]string) ArchiverOption
- func WithArchiverRecovery(pct int) ArchiverOption
- func WithArchiverSplitSize(size int64) ArchiverOption
- func WithArchiverXattrs(b bool) ArchiverOption
- type BlockOffset
- type BlockOffsetExporter
- type BlockOffsetImporter
- type Compressor
- type Decompressor
- type Extractor
- type ExtractorOption
- func WithExtractorChownErrorHandler(fn func(name string, err error) error) ExtractorOption
- func WithExtractorConcurrency(n int) ExtractorOption
- func WithExtractorIncremental(b bool) ExtractorOption
- func WithExtractorKeepBroken(b bool) ExtractorOption
- func WithExtractorKeepNewerFiles(keep bool) ExtractorOption
- func WithExtractorKeepOldFiles(keep bool) ExtractorOption
- func WithExtractorMaxFileSize(n int64) ExtractorOption
- func WithExtractorMaxRatio(n int64) ExtractorOption
- func WithExtractorNoTimes(noTimes bool) ExtractorOption
- func WithExtractorNumericOwner(b bool) ExtractorOption
- func WithExtractorPassword(p string) ExtractorOption
- func WithExtractorSafeWrites(b bool) ExtractorOption
- func WithExtractorSparse(b bool) ExtractorOption
- func WithExtractorStripComponents(count int) ExtractorOption
- func WithExtractorTolerant(b bool) ExtractorOption
- func WithExtractorUnlinkFirst(b bool) ExtractorOption
- func WithExtractorXattrs(b bool) ExtractorOption
- type FSOption
- type FileNode
- type Format
- type GzipIndexExporter
- type GzipIndexImporter
- type Header
- type Index
- func (idx *Index) Close() error
- func (idx *Index) GetClosestBlockOffset(table string, targetDataOffset int64) (*BlockOffset, error)
- func (idx *Index) GetGzipIndex() ([]byte, error)
- func (idx *Index) InitMetadata() error
- func (idx *Index) Insert(nodes []FileNode) error
- func (idx *Index) InsertBlockOffsets(table string, offsets []BlockOffset) error
- func (idx *Index) List(p string) ([]FileNode, error)
- func (idx *Index) Lookup(p string) (*FileNode, error)
- func (idx *Index) RecursiveSize(p string) (int64, error)
- func (idx *Index) SaveGzipIndex(data []byte) error
- type MultiVolumeReader
- type MultiVolumeWriter
- type ReadCloser
- type Reader
- type TarFS
- type Updater
- type WriteCloser
- type Writer
- type WriterOption
- type XCryptHeader
Constants ¶
const ( Store uint16 = 0 GZIP uint16 = 1 BZIP2 uint16 = 2 XZ uint16 = 3 ZSTD uint16 = 4 )
Compression formats
const ( TypeReg = tar.TypeReg TypeRegA = tar.TypeRegA TypeLink = tar.TypeLink TypeSymlink = tar.TypeSymlink TypeChar = tar.TypeChar TypeBlock = tar.TypeBlock TypeDir = tar.TypeDir TypeFifo = tar.TypeFifo TypeCont = tar.TypeCont TypeXHeader = tar.TypeXHeader TypeXGlobalHeader = tar.TypeXGlobalHeader TypeGNUSparse = tar.TypeGNUSparse TypeGNULongName = tar.TypeGNULongName TypeGNULongLink = tar.TypeGNULongLink TypeVol = 'V' // GNUTYPE_VOLHDR (Volume header) TypeGNUDumpDir = 'D' // GNUTYPE_DUMPDIR TypeGNUMultiVol = 'M' // GNUTYPE_MULTIVOL )
const ( FormatUnknown = tar.FormatUnknown FormatUSTAR = tar.FormatUSTAR FormatPAX = tar.FormatPAX FormatGNU = tar.FormatGNU )
const MappedStringMark = '\uFFFE'
const MappedStringMarkStr = "\uFFFE"
Variables ¶
var ( ErrHeader = tar.ErrHeader ErrWriteTooLong = tar.ErrWriteTooLong ErrFieldTooLong = tar.ErrFieldTooLong ErrWriteAfterClose = tar.ErrWriteAfterClose )
var ErrAlgorithm = errors.New("tar: unsupported compression algorithm")
var ErrArchiveLocked = errors.New("tar: cannot modify archive, it is locked")
Functions ¶
func AppendTarRecoveryRecord ¶ added in v0.1.33
AppendTarRecoveryRecord генерирует PAR2 для TAR-архива и дописывает его в хвост с F4-футером
func DetectFormat ¶
DetectFormat looks at the magic bytes to determine the compression method.
func GetStandardIndexPath ¶ added in v0.1.10
GetStandardIndexPath attempts to place the SQLite index next to the archive (sidecar). If the directory is read-only, it falls back to the user's cache directory.
func IndexArchive ¶
func LocateShadowStream ¶ added in v0.1.32
LocateShadowStream finds the F4SS Magic Footer and returns the physical offset and size of Stream 2.
func RegisterCompressor ¶
func RegisterCompressor(method uint16, comp Compressor)
func RegisterDecompressor ¶
func RegisterDecompressor(method uint16, dcomp Decompressor)
Types ¶
type Archiver ¶
type Archiver struct {
// contains filtered or unexported fields
}
func NewArchiver ¶
func NewArchiver(filename string, chroot string, opts ...ArchiverOption) (*Archiver, error)
func (*Archiver) Archive ¶
Archive writes files to the tar sequentially. For TAR, unlike ZIP, we cannot write data streams concurrently to the same file.
func (*Archiver) SetComment ¶ added in v0.1.40
SetComment sets the global archive comment stored inside the F4SS shadow metadata index.
type ArchiverOption ¶
type ArchiverOption func(*archiverOptions) error
func WithArchiverEmbeddedIndex ¶ added in v0.1.28
func WithArchiverEmbeddedIndex(b bool) ArchiverOption
func WithArchiverIndex ¶ added in v0.1.8
func WithArchiverIndex(path string) ArchiverOption
func WithArchiverLevel ¶ added in v0.1.47
func WithArchiverLevel(level int) ArchiverOption
WithArchiverLevel sets the compression level.
func WithArchiverLock ¶ added in v0.1.40
func WithArchiverLock(b bool) ArchiverOption
WithArchiverLock locks the archive to prevent modifications.
func WithArchiverMethod ¶
func WithArchiverMethod(method uint16) ArchiverOption
func WithArchiverPassword ¶ added in v0.1.32
func WithArchiverPassword(p string) ArchiverOption
WithArchiverEmbeddedIndex appends the index directly inside the archive (F4 Shadow Stream). WithArchiverPassword enables F4Crypt AES-256-CTR encryption for the archive.
func WithArchiverPathMapping ¶ added in v0.1.57
func WithArchiverPathMapping(m map[string]string) ArchiverOption
WithArchiverPathMapping sets the path mapping for logical names in the archive.
func WithArchiverRecovery ¶ added in v0.1.34
func WithArchiverRecovery(pct int) ArchiverOption
WithArchiverRecovery устанавливает процент избыточности PAR2 для защиты архива
func WithArchiverSplitSize ¶ added in v0.1.37
func WithArchiverSplitSize(size int64) ArchiverOption
WithArchiverSplitSize enables creation of multi-volume archives
func WithArchiverXattrs ¶ added in v0.1.13
func WithArchiverXattrs(b bool) ArchiverOption
WithArchiverXattrs enables archiving of extended attributes (xattrs, POSIX ACLs, SELinux).
type BlockOffset ¶ added in v0.1.1
type BlockOffsetExporter ¶ added in v0.1.1
type BlockOffsetExporter interface {
ExportBlockOffsets() []BlockOffset
}
BlockOffsetExporter exports boundary maps for block-based compression formats (ZSTD, BZIP2).
type BlockOffsetImporter ¶ added in v0.1.1
type BlockOffsetImporter interface {
ResumeFromBlockOffset(r io.ReaderAt, bo *BlockOffset) (io.ReadCloser, error)
}
BlockOffsetImporter resumes decompression from a specific block boundary.
type Compressor ¶
type Compressor func(w io.Writer) (io.WriteCloser, error)
type Decompressor ¶
type Decompressor interface {
Decompress(r io.Reader) (io.ReadCloser, error)
}
type Extractor ¶
type Extractor struct {
// contains filtered or unexported fields
}
func NewExtractor ¶
func NewExtractor(filename, chroot string, opts ...ExtractorOption) (*Extractor, error)
type ExtractorOption ¶
type ExtractorOption func(*extractorOptions) error
func WithExtractorChownErrorHandler ¶
func WithExtractorChownErrorHandler(fn func(name string, err error) error) ExtractorOption
WithExtractorChownErrorHandler allows gracefully ignoring chown errors which frequently happen when extracting archives as an unprivileged user.
func WithExtractorConcurrency ¶
func WithExtractorConcurrency(n int) ExtractorOption
func WithExtractorIncremental ¶ added in v0.1.13
func WithExtractorIncremental(b bool) ExtractorOption
WithExtractorIncremental enables processing of GNU Dumpdir headers to remove deleted files during incremental restores.
func WithExtractorKeepBroken ¶ added in v0.1.22
func WithExtractorKeepBroken(b bool) ExtractorOption
func WithExtractorKeepNewerFiles ¶ added in v0.1.13
func WithExtractorKeepNewerFiles(keep bool) ExtractorOption
WithExtractorKeepNewerFiles prevents overwriting files that are newer on disk (--keep-newer-files)
func WithExtractorKeepOldFiles ¶ added in v0.1.13
func WithExtractorKeepOldFiles(keep bool) ExtractorOption
WithExtractorKeepOldFiles prevents overwriting existing files (-k or --keep-old-files)
func WithExtractorMaxFileSize ¶
func WithExtractorMaxFileSize(n int64) ExtractorOption
func WithExtractorMaxRatio ¶
func WithExtractorMaxRatio(n int64) ExtractorOption
func WithExtractorNoTimes ¶ added in v0.1.13
func WithExtractorNoTimes(noTimes bool) ExtractorOption
WithExtractorNoTimes prevents restoring original modification times (-m / --touch)
func WithExtractorNumericOwner ¶ added in v0.1.13
func WithExtractorNumericOwner(b bool) ExtractorOption
WithExtractorNumericOwner always uses numeric user/group IDs from the archive rather than resolving Uname/Gname (--numeric-owner).
func WithExtractorPassword ¶ added in v0.1.32
func WithExtractorPassword(p string) ExtractorOption
WithExtractorSafeWrites extracts files atomically by writing to a temporary file and renaming (--safe-writes). WithExtractorPassword provides the password for decrypting F4Crypt encrypted archives.
func WithExtractorSafeWrites ¶ added in v0.1.13
func WithExtractorSafeWrites(b bool) ExtractorOption
func WithExtractorSparse ¶ added in v0.1.13
func WithExtractorSparse(b bool) ExtractorOption
WithExtractorSparse enables extracting files as sparse files by seeking over zero-blocks (-S, --sparse).
func WithExtractorStripComponents ¶ added in v0.1.13
func WithExtractorStripComponents(count int) ExtractorOption
WithExtractorStripComponents strips the specified number of leading components from file names on extraction (--strip-components)
func WithExtractorTolerant ¶ added in v0.1.25
func WithExtractorTolerant(b bool) ExtractorOption
func WithExtractorUnlinkFirst ¶ added in v0.1.13
func WithExtractorUnlinkFirst(b bool) ExtractorOption
WithExtractorUnlinkFirst removes existing files prior to extracting over them (-U, --unlink-first).
func WithExtractorXattrs ¶ added in v0.1.13
func WithExtractorXattrs(b bool) ExtractorOption
WithExtractorXattrs enables restoration of extended attributes (xattrs, POSIX ACLs, SELinux).
type FSOption ¶ added in v0.1.32
type FSOption func(*fsOptions)
func WithFSPassword ¶ added in v0.1.32
WithFSPassword provides the password for decrypting F4Crypt encrypted archives in TarFS.
type GzipIndexExporter ¶ added in v0.1.1
GzipIndexExporter exports the complete serialized GZIP index (compatible with zran.c/rapidgzip).
type GzipIndexImporter ¶ added in v0.1.1
type GzipIndexImporter interface {
ResumeFromGzipIndex(r io.ReaderAt, indexData []byte, targetOffset int64) (reader io.ReadCloser, uncompOffset int64, err error)
}
GzipIndexImporter resumes GZIP decompression using the serialized index.
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
func (*Index) GetClosestBlockOffset ¶ added in v0.1.1
func (idx *Index) GetClosestBlockOffset(table string, targetDataOffset int64) (*BlockOffset, error)
func (*Index) GetGzipIndex ¶ added in v0.1.1
func (*Index) InitMetadata ¶ added in v0.1.29
func (*Index) InsertBlockOffsets ¶ added in v0.1.1
func (idx *Index) InsertBlockOffsets(table string, offsets []BlockOffset) error
func (*Index) SaveGzipIndex ¶ added in v0.1.1
type MultiVolumeReader ¶ added in v0.1.37
type MultiVolumeReader struct {
// contains filtered or unexported fields
}
func OpenMultiVolume ¶ added in v0.1.37
func OpenMultiVolume(mainPath string, flag int) (*MultiVolumeReader, int64, error)
func (*MultiVolumeReader) Append ¶ added in v0.1.37
func (m *MultiVolumeReader) Append(data []byte) error
func (*MultiVolumeReader) Close ¶ added in v0.1.37
func (m *MultiVolumeReader) Close() error
type MultiVolumeWriter ¶ added in v0.1.37
type MultiVolumeWriter struct {
// contains filtered or unexported fields
}
func NewMultiVolumeWriter ¶ added in v0.1.37
func NewMultiVolumeWriter(mainPath string, splitSize int64) (*MultiVolumeWriter, error)
func (*MultiVolumeWriter) Close ¶ added in v0.1.37
func (m *MultiVolumeWriter) Close() error
func (*MultiVolumeWriter) Name ¶ added in v0.1.37
func (m *MultiVolumeWriter) Name() string
func (*MultiVolumeWriter) Sync ¶ added in v0.1.37
func (m *MultiVolumeWriter) Sync() error
type ReadCloser ¶
func OpenReader ¶
func OpenReader(name string) (*ReadCloser, error)
OpenReader opens a TAR or compressed TAR file (.tar, .tar.gz, .tar.zst, etc.).
func (*ReadCloser) Close ¶
func (rc *ReadCloser) Close() error
func (*ReadCloser) Next ¶ added in v0.1.42
func (rc *ReadCloser) Next() (*Header, error)
type TarFS ¶
type TarFS struct {
ArchivePath string
IndexPath string
Index *Index
// contains filtered or unexported fields
}
func NewFS ¶
NewFS opens a tar archive as a standard Go fs.FS (File System). This enables integration with http.FileServer, fs.WalkDir, etc. If the SQLite index does not exist, it will be generated automatically.
func (*TarFS) GetComment ¶ added in v0.1.40
GetComment retrieves the global archive comment stored in the F4SS shadow metadata index.
type Updater ¶
type Updater struct {
// contains filtered or unexported fields
}
func NewUpdater ¶
func NewUpdater(f *os.File, mode AppendMode) (*Updater, error)
NewUpdater opens a .tar or compressed .tar file for appending.
func (*Updater) AppendReader ¶ added in v0.1.63
AppendReader creates a new file entry in the archive from an io.Reader stream.
type WriteCloser ¶
func CreateWriter ¶
func CreateWriter(name string, method uint16, opts ...WriterOption) (*WriteCloser, error)
func (*WriteCloser) Close ¶
func (wc *WriteCloser) Close() error
func (*WriteCloser) WriteHeader ¶ added in v0.1.8
func (wc *WriteCloser) WriteHeader(hdr *Header) error
type WriterOption ¶ added in v0.1.8
type WriterOption func(*writerOptions)
func WithWriterIndex ¶ added in v0.1.8
func WithWriterIndex(indexPath string) WriterOption
WithWriterIndex enables on-the-fly indexing during archive creation.
func WithWriterLevel ¶ added in v0.1.47
func WithWriterLevel(level int) WriterOption
func WithWriterSplitSize ¶ added in v0.1.37
func WithWriterSplitSize(size int64) WriterOption
type XCryptHeader ¶ added in v0.1.49
type XCryptHeader struct {
Version uint8
KdfAlgo uint8
Cipher uint8
Iterations uint32
Salt []byte
IV []byte
MAC []byte
}
XCryptHeader represents the 93-byte binary header for encrypted streams
func (*XCryptHeader) DeriveKey ¶ added in v0.1.49
func (h *XCryptHeader) DeriveKey(password string) []byte
func (*XCryptHeader) Encode ¶ added in v0.1.49
func (h *XCryptHeader) Encode() []byte