Documentation
¶
Overview ¶
Package filesystem contains a simple representation of hierarchical filesystems that is used by libpackagebuild.
Index ¶
- type Directory
- func (d *Directory) FileModeForArchive(includingFileType bool) uint32
- func (d *Directory) Insert(entry Node, relPath []string, location string) error
- func (d *Directory) InstalledSizeInBytes() int
- func (d *Directory) PostponeUnmaterializable(absolutePath string) string
- func (d *Directory) ToTarArchive(w io.Writer, leadingDot, skipRootDirectory bool) error
- func (d *Directory) ToTarGZArchive(w io.Writer, leadingDot, skipRootDirectory bool) error
- func (d *Directory) ToTarXZArchive(w io.Writer, leadingDot, skipRootDirectory bool) error
- func (d *Directory) Walk(absolutePath string, callback func(string, Node) error) error
- type IntOrString
- type Node
- type NodeMetadata
- type RegularFile
- func (f *RegularFile) FileModeForArchive(includingFileType bool) uint32
- func (f *RegularFile) Insert(entry Node, relPath []string, location string) error
- func (f *RegularFile) InstalledSizeInBytes() int
- func (f *RegularFile) MD5Digest() string
- func (f *RegularFile) PostponeUnmaterializable(absolutePath string) string
- func (f *RegularFile) SHA256Digest() string
- func (f *RegularFile) Walk(absolutePath string, callback func(string, Node) error) error
- type Symlink
- func (s *Symlink) FileModeForArchive(includingFileType bool) uint32
- func (s *Symlink) Insert(entry Node, relPath []string, location string) error
- func (s *Symlink) InstalledSizeInBytes() int
- func (s *Symlink) PostponeUnmaterializable(absolutePath string) string
- func (s *Symlink) Walk(absolutePath string, callback func(string, Node) error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Directory ¶
type Directory struct {
Entries map[string]Node
Metadata NodeMetadata
Implicit bool
}
Directory is a type of Node that represents directories. This Node references the nodes contained in the directory recursively.
func (*Directory) FileModeForArchive ¶
FileModeForArchive implements the Node interface.
func (*Directory) InstalledSizeInBytes ¶
InstalledSizeInBytes implements the Node interface.
func (*Directory) PostponeUnmaterializable ¶
PostponeUnmaterializable implements the Node interface.
func (*Directory) ToTarArchive ¶
ToTarArchive creates a TAR archive containing this directory and all the filesystem entries in it.
With `leadingDot = true`, generate entry paths like `./foo/bar.conf`. With `leadingDot = false`, generate entry paths like `foo/bar.conf`.
With `skipRootDirectory = true`, don't generate an entry for the root directory in the resulting package.
func (*Directory) ToTarGZArchive ¶
ToTarGZArchive is identical to ToTarArchive, but GZip-compresses the result.
func (*Directory) ToTarXZArchive ¶
ToTarXZArchive is identical to ToTarArchive, but GZip-compresses the result.
type IntOrString ¶
IntOrString is used for NodeMetadata.Owner and NodeMetadata.Group that can be either int or string.
Note that, from within a generator, you will always see `Str` to be empty. See Node.PostponeUnmaterializable() for details.
type Node ¶
type Node interface {
//Insert inserts a new node below the current node at the given relative
//path. The path is given as a slice of strings, separated on slashes, e.g.
//`[]string{"var","lib","foo"}` for the path `"var/lib/foo"`.
//
//The `location` argument contains the absolute path to the current node;
//this can be used for error reporting.
Insert(entry Node, relPath []string, location string) error
//InstalledSizeInBytes approximates the apparent size of the given
//directory and everything in it, as calculated by `du -s --apparent-size`,
//but in a filesystem-independent way.
InstalledSizeInBytes() int
//FileModeForArchive returns the file mode of this Node as stored in a
//tar or CPIO archive.
FileModeForArchive(includingFileType bool) uint32
//Walk visits all the nodes below this Node (including itself) and calls
//the given callback at each node. It is guaranteed that the callback for a
//node is called after the callback of its parent node (if any).
//
//The `callback` can arrange to skip over a directory by returning
//filepath.SkipDir.
Walk(absolutePath string, callback func(absolutePath string, node Node) error) error
//PostponeUnmaterializable generates a shell script that applies all
//filesystem metadata in this node and its children that cannot be
//represented in a tar archive directly. Specifically, owners/groups
//identified by name cannot be resolved into numeric IDs at build time, so
//this call will generate a shell script calling chown/chmod/chgrp as
//required.
PostponeUnmaterializable(absolutePath string) string
}
Node instances represent an entry in the file system (such as a file or a directory).
type NodeMetadata ¶
type NodeMetadata struct {
Mode os.FileMode
Owner *IntOrString
Group *IntOrString
}
NodeMetadata collects some metadata that is shared across Node-compatible types.
type RegularFile ¶
type RegularFile struct {
Content string
Metadata NodeMetadata
}
RegularFile is a type of Node that represents regular files.
func (*RegularFile) FileModeForArchive ¶
func (f *RegularFile) FileModeForArchive(includingFileType bool) uint32
FileModeForArchive implements the Node interface.
func (*RegularFile) Insert ¶
func (f *RegularFile) Insert(entry Node, relPath []string, location string) error
Insert implements the Node interface.
func (*RegularFile) InstalledSizeInBytes ¶
func (f *RegularFile) InstalledSizeInBytes() int
InstalledSizeInBytes implements the Node interface.
func (*RegularFile) MD5Digest ¶
func (f *RegularFile) MD5Digest() string
MD5Digest returns the MD5 digest of this file's contents.
func (*RegularFile) PostponeUnmaterializable ¶
func (f *RegularFile) PostponeUnmaterializable(absolutePath string) string
PostponeUnmaterializable implements the Node interface.
func (*RegularFile) SHA256Digest ¶
func (f *RegularFile) SHA256Digest() string
SHA256Digest returns the SHA256 digest of this file's contents.
type Symlink ¶
type Symlink struct {
Target string
}
Symlink is a type of Node that represents symbolic links,
func (*Symlink) FileModeForArchive ¶
FileModeForArchive implements the Node interface.
func (*Symlink) InstalledSizeInBytes ¶
InstalledSizeInBytes implements the Node interface.
func (*Symlink) PostponeUnmaterializable ¶
PostponeUnmaterializable implements the Node interface.