gsc

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2023 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package gsc implements data structure and utils used by gsc cmd

Index

Constants

View Source
const LinkStateDead = "dead"

LinkStateDead is the invalid state of a symlink

View Source
const LinkStateValid = "valid"

LinkStateValid is the valid state of a symlink

View Source
const TypeDirectory = "dir"

TypeDirectory represents a directory in portage

View Source
const TypeFile = "obj"

TypeFile represents a file in portage

View Source
const TypeSymlink = "sym"

TypeSymlink represents a symlink in portage

Variables

View Source
var ErrDeadLink = errors.New(LinkStateDead)

ErrDeadLink is the error in case of dead link

Functions

func BuildPackageMap

func BuildPackageMap(filesystem fs.FS, dbPath string) (entries map[string]*PkgItem)

BuildPackageMap builds an map with path as key and PkgItem as value of portage database content

func CheckErr

func CheckErr(err error)

CheckErr check error, log and exit if err is not nil

func GetItemType

func GetItemType(info fs.FileInfo) (string, error)

GetItemType returns the portage type from a real file (info)

func IsExcluded

func IsExcluded(ignorePatterns []string, path string) bool

IsExcluded checks if a path is excluded from check

func LoadIgnorePatterns

func LoadIgnorePatterns(filesystem fs.FS, filename string) []string

LoadIgnorePatterns loads patterns from a .gscignore file.

func WalkSymlink(filesystem ExFS, path string) (string, string, error)

WalkSymlink walks through a symlink

Types

type ExDirFs

type ExDirFs string

ExDirFs is the base ExFS implementation

func (ExDirFs) Lstat

func (f ExDirFs) Lstat(name string) (os.FileInfo, error)

Lstat returns a fs.FileInfo for name

func (ExDirFs) Open

func (f ExDirFs) Open(name string) (fs.File, error)

Open file by name

func (f ExDirFs) Readlink(name string) (string, error)

Readlink by name

type ExFS

type ExFS interface {
	fs.FS
	Readlink(name string) (string, error)
	Lstat(name string) (os.FileInfo, error)
}

ExFS is an fs.FS extension with symlink operations

func DirFs

func DirFs(dir string) ExFS

DirFs creates an ExDirFS

type FsItem

type FsItem struct {
	Typ       string      // object type
	Path      string      // real path
	Target    string      // target, only if typ is symlink
	Endtarget string      // last no (valid) symlink recursive target
	Md5       []byte      // checksum of the file if typ is obj (file)
	Info      fs.FileInfo // file info
	LinkState string      // state of the link if symlink
}

FsItem represents a file on the filesystem

func NewFsItem

func NewFsItem(filesystem ExFS, path string, info fs.FileInfo) (*FsItem, error)

NewFsItem create new FsItem from path and info

type PkgItem

type PkgItem struct {
	Typ    string
	Path   string
	Target string
	Cat    string
	Pkg    string
	Md5    []byte
	Mtime  time.Time
}

PkgItem represents as known as portage database

func NewPkgItem

func NewPkgItem(cat, pkg, line string) (pkgItem *PkgItem, err error)

NewPkgItem creates a PkgItem from a raw line of portage database

Jump to

Keyboard shortcuts

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