common

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package common provides common utilities for embedded filesystem extractors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectFilesystem

func DetectFilesystem(r io.ReaderAt, offset int64) string

DetectFilesystem identifies the filesystem type by magic bytes.

func ExtractAllRecursiveExFAT

func ExtractAllRecursiveExFAT(section *io.SectionReader, dst string) error

ExtractAllRecursiveExFAT extracts all files from an exFAT filesystem to a temporary directory recursively.

func ExtractAllRecursiveExt

func ExtractAllRecursiveExt(fs *ext4.FileSystem, srcPath, destPath string) error

ExtractAllRecursiveExt extracts all files from an ext4 filesystem to a temporary directory recursively.

func ExtractAllRecursiveFat32

func ExtractAllRecursiveFat32(fs *fat32.FileSystem, srcPath, destPath string) error

ExtractAllRecursiveFat32 extracts all files from a FAT32 filesystem to a temporary directory recursively.

func ExtractAllRecursiveNtfs

func ExtractAllRecursiveNtfs(fs *parser.NTFSContext, srcPath, destPath string) error

ExtractAllRecursiveNtfs extracts all files from a NTFS filesystem to a temporary directory recursively.

func GetDiskPartitions

func GetDiskPartitions(tmpRawPath string) ([]part.Partition, *disk.Disk, error)

GetDiskPartitions opens a raw disk image and returns its partitions along with the disk handle.

func NewPartitionEmbeddedFSGetter

func NewPartitionEmbeddedFSGetter(pluginName string, partitionIndex int, p part.Partition, disk *disk.Disk, tmpRawPath string, refMu *sync.Mutex, refCount *int32) func(context.Context) (scalibrfs.FS, error)

NewPartitionEmbeddedFSGetter creates a lazy getter function for an embedded filesystem from a disk partition.

func TARToTempDir

func TARToTempDir(reader io.Reader) (string, error)

TARToTempDir extracts a tar file into a temporary directory that can be used to traverse its contents recursively.

Types

type CloserWithTmpPaths

type CloserWithTmpPaths interface {
	scalibrfs.FS
	Close() error
	TempPaths() []string
}

CloserWithTmpPaths is an interface for filesystems that provide temporary paths for cleanup.

type EmbeddedDirFS

type EmbeddedDirFS struct {
	FS       scalibrfs.FS
	File     *os.File
	TmpPaths []string
	RefCount *int32
	RefMu    *sync.Mutex
}

EmbeddedDirFS wraps scalibrfs.DirFS to include reference counting and cleanup.

func (*EmbeddedDirFS) Close

func (e *EmbeddedDirFS) Close() error

Close closes the underlying file without removing temporary paths.

func (*EmbeddedDirFS) Open

func (e *EmbeddedDirFS) Open(name string) (fs.File, error)

Open opens the specified file from the embedded filesystem.

func (*EmbeddedDirFS) ReadDir

func (e *EmbeddedDirFS) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir returns a list of directory entries for the specified path. If name is empty or "/", it reads from the root directory instead.

func (*EmbeddedDirFS) Stat

func (e *EmbeddedDirFS) Stat(name string) (fs.FileInfo, error)

Stat returns a FileInfo describing the named file or directory. If the name refers to the root directory ("/", "", or "."), it returns a synthetic FileInfo representing a directory.

func (*EmbeddedDirFS) TempPaths

func (e *EmbeddedDirFS) TempPaths() []string

TempPaths returns the temporary paths associated with the filesystem for cleanup.

Jump to

Keyboard shortcuts

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