fs

package
v0.0.0-...-de93790 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TmpDir

func TmpDir() string

TmpDir returns the base directory to use for temp files/directories

Types

type CopyCollector

type CopyCollector struct {
	DstDir string // the destination directory to copy to
}

CopyCollector collects files by copying them to a destination directory

func (*CopyCollector) WriteFile

func (cc *CopyCollector) WriteFile(fpath string, fi fs.FileInfo, linkName string, f io.Reader) error

WriteFile writes the given fpath to the destination directory for this CopyCollector

type DefaultFs

type DefaultFs struct {
}

DefaultFs provides a default implementation of the [FileCollectorFS] interface

func (*DefaultFs) Open

func (*DefaultFs) Open(path string) (io.ReadCloser, error)

Open opens a path

func (*DefaultFs) OpenGitIndex

func (*DefaultFs) OpenGitIndex(path string) (*index.Index, error)

OpenGitIndex opens the git index file

func (*DefaultFs) Readlink(path string) (string, error)

Readlink reads a link at path

func (*DefaultFs) Walk

func (*DefaultFs) Walk(root string, fn filepath.WalkFunc) error

Walk walks the file tree rooted at root, calling fn for each file

type FileCollector

type FileCollector struct {
	Ignorer   gitignore.Matcher
	SrcPath   string
	SrcPrefix string
	Fs        FileCollectorFs
	Handler   FileCollectorHandler
}

FileCollector collects files from a git index

func (*FileCollector) CollectFiles

func (fc *FileCollector) CollectFiles(ctx context.Context, submodulePath []string) filepath.WalkFunc

CollectFiles provides a WalkFunc to collect files in a git index

type FileCollectorFs

type FileCollectorFs interface {
	Walk(root string, fn filepath.WalkFunc) error
	OpenGitIndex(path string) (*index.Index, error)
	Open(path string) (io.ReadCloser, error)
	Readlink(path string) (string, error)
}

FileCollectorFs provides an interface for a file system

type FileCollectorHandler

type FileCollectorHandler interface {
	WriteFile(path string, fi fs.FileInfo, linkName string, f io.Reader) error
}

FileCollectorHandler provides an interface to collect files

type TarCollector

type TarCollector struct {
	TarWriter *tar.Writer // the writer to use for files
	UID       int         // UID to apply to files in the tar
	GID       int         // GID to apply to files in the tar
	DstDir    string      // DstDir is prefixed on files collected before being added to the tar file
}

TarCollector collects files to a tar file

func (TarCollector) WriteFile

func (tc TarCollector) WriteFile(fpath string, fi fs.FileInfo, linkName string, f io.Reader) error

WriteFile adds a file at fpath to the tar file

type ZipCollector

type ZipCollector struct {
	ZipWriter *zip.Writer // the zip writer to write files to
}

ZipCollector is a Collector that writes files to a zip file

func (ZipCollector) WriteFile

func (zc ZipCollector) WriteFile(fpath string, fi fs.FileInfo, _ string, f io.Reader) error

WriteFile writes files to a zip file

Jump to

Keyboard shortcuts

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