Documentation
¶
Overview ¶
Package files provides a simple file tree abstraction.
It is specifically designed to match the simple needs for building a simple initramfs. So it only supports file types for regular files, directories and symbolic links.
Index ¶
- Variables
- func LinkedLibs(elfFilePath string) ([]string, error)
- type ELFLibResolver
- type Entry
- func (e *Entry) AddDirectory(name string) (*Entry, error)
- func (e *Entry) AddEntry(name string, entry *Entry) (*Entry, error)
- func (e *Entry) AddFile(name, relatedPath string) (*Entry, error)
- func (e *Entry) AddLink(name, relatedPath string) (*Entry, error)
- func (e *Entry) GetEntry(name string) (*Entry, error)
- func (e *Entry) IsDir() bool
- func (e *Entry) IsLink() bool
- func (e *Entry) IsRegular() bool
- type Tree
- type Type
- type WalkFunc
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEntryNotDir is returned if an entry is supposed to be a directory but is // not. ErrEntryNotDir = errors.New("entry is not a directory") // ErrEntryNotExists is returned if an entry that is looked up does not exist. ErrEntryNotExists = errors.New("entry does not exist") // ErrEntryExists is returned if an entry exists that was not expected. ErrEntryExists = errors.New("entry exists") )
Functions ¶
func LinkedLibs ¶ added in v0.1.1
LinkedLibs fetches the list of dynamically linked libraries from the ELF file.
Types ¶
type ELFLibResolver ¶
ELFLibResolver resolves dynamically linked libraries of ELF file. It collects the libraries deduplicated for all files resolved with ELFLibResolver.Resolve.
func (*ELFLibResolver) Resolve ¶
func (r *ELFLibResolver) Resolve(elfFile string) error
Resolve analyzes the required linked libraries of the ELF file with the given path. The libraries are search for in the library search paths and are added with their absolute path to ELFLibResolver's list of libs. Call [ELFLibResolver.Libs] once all files are resolved.
type Entry ¶
type Entry struct { // Type of this entry. Type Type // Related path depending on the file type. Empty for directories, // target path for links, source files for regular files. RelatedPath string // contains filtered or unexported fields }
Entry is a single file tree entry.
func (*Entry) AddDirectory ¶
AddDirectory adds a new directory Entry children.
func (*Entry) AddEntry ¶
AddEntry adds an arbitrary Entry as children. The caller is responsible for using only valid [Type]s and according fields.
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree represents a simple file tree.
func (*Tree) GetEntry ¶
GetEntry returns the entry for the given path. Returns ErrEntryNotExists if the entry does not exist.