drive

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const NTFSSbMagic = 0x5346544e
View Source
const SysNewFstatat = 262

Variables

View Source
var InoFilterInstance = InoFilter{
	// contains filtered or unexported fields
}

Functions

func Explore

func Explore(path string) error

func HiddenFilter added in v0.1.2

func HiddenFilter(fi FileInfo) bool

HiddenFilter filters all hidden files and directories (with a dot prefix) and returns a corresponding boolean value.

func UTF16ToString added in v0.6.0

func UTF16ToString(alloc Allocator, s []uint16) string

UTF16ToString is a copy of the standard syscall.UTF16ToString function, except it uses a buffer pool instead of creating a new one on each call.

Types

type Allocator added in v0.6.0

type Allocator interface {
	// Alloc allocates the required number of bytes using the specific allocator
	// implementation. If the memory region cannot be allocated an error will be
	// returned.
	Alloc(size uint32) ([]byte, error)
}

Allocator defines a basic interface for the arena allocator.

type FileInfo

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

FileInfo defines a custom fs.FileInfo implementation for wrapping the results from the file info system calls.

func NewFileInfo

func NewFileInfo(name string, data *unix.Stat_t) FileInfo

func ReadDir

func ReadDir(alloc Allocator, path string) ([]FileInfo, error)

func (FileInfo) IsDir

func (fi FileInfo) IsDir() bool

func (FileInfo) ModTime

func (fi FileInfo) ModTime() int64

func (FileInfo) Mode

func (fi FileInfo) Mode() os.FileMode

func (FileInfo) Name

func (fi FileInfo) Name() string

func (FileInfo) Size

func (fi FileInfo) Size() int64

func (FileInfo) Sys

func (fi FileInfo) Sys() any

type FileInfoFilter added in v0.1.2

type FileInfoFilter func(FileInfo) bool

FileInfoFilter defines a custom function type for filtering *FileInfo instances against specific rules. The type implementation only tells if the current *FileInfo meets the specification by returning a boolean value.

type Info

type Info struct {
	Path        string  `json:"path"`
	Volume      string  `json:"volume"`
	FSName      string  `json:"fsName"`
	Device      string  `json:"device"`
	TotalBytes  uint64  `json:"total"`
	FreeBytes   uint64  `json:"free"`
	UsedBytes   uint64  `json:"used"`
	UsedPercent float64 `json:"usedPercent"`
	IsDev       uint8   `json:"isDev"`
}

Info contains information about a single drive/volume/mount. The data can be fetched using a corresponding operating system syscall against a target entry.

type InoFilter added in v0.1.0

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

InoFilter filters files by inode value, preventing the double calculation of the same space on the disk. The filter must be manually reset before each new volume scan.

func (*InoFilter) Add added in v0.1.0

func (inf *InoFilter) Add(inode uint64) bool

Add adds a new inode value to the filter. It returns a bool value depending on whether the inode already exists - "false", or adds it to the filter - "true".

func (*InoFilter) Reset added in v0.1.0

func (inf *InoFilter) Reset()

type List

type List struct {
	TotalCapacity uint64
	TotalUsed     uint64
	TotalFree     uint64
	MountsLayout  bool
	// contains filtered or unexported fields
}

func NewList

func NewList() (*List, error)

func (*List) All

func (l *List) All() map[string]*Info

func (*List) DriveInfo

func (l *List) DriveInfo(path string) *Info

func (*List) Find

func (l *List) Find(diskPath string) *Info

func (*List) Sort

func (l *List) Sort(sk SortKey, desc bool) []*Info

type SizeFilter added in v0.1.2

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

SizeFilter provided a FileInfoFilter implementation responsible for filtering FileInfo file instances by their size. The file's size must be within the defined boundaries, otherwise, it must be rejected.

The filter will check files only, and the size boundaries must be defined in bytes.

func NewSizeFilter added in v0.1.2

func NewSizeFilter(minLimit, maxLimit int64) *SizeFilter

func (*SizeFilter) Filter added in v0.1.2

func (sf *SizeFilter) Filter(fi FileInfo) bool

Filter filters the provided *FileInfo file instance by its size and returns a corresponding boolean value. For the directory type, the result will always be true.

type SortKey

type SortKey string
const (
	TotalCap   SortKey = "1"
	TotalUsed  SortKey = "2"
	TotalFree  SortKey = "3"
	TotalUsedP SortKey = "4"
)

Jump to

Keyboard shortcuts

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