pkging

package
Version: v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2020 License: MIT Imports: 7 Imported by: 34

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adder added in v0.2.0

type Adder interface {
	Add(files ...*os.File) error
}

type Details

type Details struct {
	Name    string      `json:"name"`
	Size    int64       `json:"size"`
	Mode    os.FileMode `json:"mode"`
	ModTime ModTime     `json:"mod_time"`
	IsDir   bool        `json:"is_dir"`
	Sys     interface{} `json:"sys"`
}

type File

type File interface {
	// Close closes the File, rendering it unusable for I/O.
	Close() error

	// Info returns the here.Info of the file
	Info() here.Info

	// Name retuns the name of the file
	Name() string

	// Open implements the http.FileSystem interface. A FileSystem implements access to a collection of named files. The elements in a file path are separated by slash ('/', U+002F) characters, regardless of host operating system convention.
	Open(name string) (http.File, error)

	// Path returns the here.Path of the file
	Path() here.Path

	// Read reads up to len(b) bytes from the File. It returns the number of bytes read and any error encountered. At end of file, Read returns 0, io.EOF.
	Read(p []byte) (int, error)

	// Readdir reads the contents of the directory associated with file and returns a slice of up to n FileInfo values, as would be returned by Lstat, in directory order. Subsequent calls on the same file will yield further FileInfos.
	//
	// If n > 0, Readdir returns at most n FileInfo structures. In this case, if Readdir returns an empty slice, it will return a non-nil error explaining why. At the end of a directory, the error is io.EOF.
	//
	// If n <= 0, Readdir returns all the FileInfo from the directory in a single slice. In this case, if Readdir succeeds (reads all the way to the end of the directory), it returns the slice and a nil error. If it encounters an error before the end of the directory, Readdir returns the FileInfo read until that point and a non-nil error.
	Readdir(count int) ([]os.FileInfo, error)

	// Seek sets the offset for the next Read or Write on file to offset, interpreted according to whence: 0 means relative to the origin of the file, 1 means relative to the current offset, and 2 means relative to the end. It returns the new offset and an error, if any.
	Seek(offset int64, whence int) (int64, error)

	// Stat returns the FileInfo structure describing file. If there is an error, it will be of type *PathError.
	Stat() (os.FileInfo, error)

	// Write writes len(b) bytes to the File. It returns the number of bytes written and an error, if any. Write returns a non-nil error when n != len(b).
	Write(b []byte) (int, error)
}

type FileInfo

type FileInfo struct {
	Details `json:"details"`
}

func NewFileInfo

func NewFileInfo(info os.FileInfo) *FileInfo

func (*FileInfo) IsDir

func (f *FileInfo) IsDir() bool

func (*FileInfo) ModTime

func (f *FileInfo) ModTime() time.Time

func (*FileInfo) Mode

func (f *FileInfo) Mode() os.FileMode

func (*FileInfo) Name

func (f *FileInfo) Name() string

func (*FileInfo) Size

func (f *FileInfo) Size() int64

func (*FileInfo) String

func (f *FileInfo) String() string

func (*FileInfo) Sys

func (f *FileInfo) Sys() interface{}

type ModTime

type ModTime time.Time

func (ModTime) MarshalJSON

func (m ModTime) MarshalJSON() ([]byte, error)

func (*ModTime) UnmarshalJSON

func (m *ModTime) UnmarshalJSON(b []byte) error

type Pkger

type Pkger interface {
	// Parse the string in here.Path format.
	Parse(p string) (here.Path, error)

	// Current returns the here.Info representing the current Pkger implementation.
	Current() (here.Info, error)

	// Info returns the here.Info of the here.Path
	Info(p string) (here.Info, error)

	// Create creates the named file with mode 0666 (before umask) - It's actually 0644, truncating it if it already exists. If successful, methods on the returned File can be used for I/O; the associated file descriptor has mode O_RDWR.
	Create(name string) (File, error)

	// MkdirAll creates a directory named path, along with any necessary parents, and returns nil, or else returns an error. The permission bits perm (before umask) are used for all directories that MkdirAll creates. If path is already a directory, MkdirAll does nothing and returns nil.
	MkdirAll(p string, perm os.FileMode) error

	// Open opens the named file for reading. If successful, methods on the returned file can be used for reading; the associated file descriptor has mode O_RDONLY.
	// @Parser Directive
	Open(name string) (File, error)

	// Stat returns a FileInfo describing the named file.
	// @Parser Directive
	Stat(name string) (os.FileInfo, error)

	// Walk walks the file tree rooted at root, calling walkFn for each file or directory in the tree, including root. All errors that arise visiting files and directories are filtered by walkFn. The files are walked in lexical order, which makes the output deterministic but means that for very large directories Walk can be inefficient. Walk does not follow symbolic links. - That is from the standard library. I know. Their grammar teachers can not be happy with them right now.
	// @Parser Directive
	Walk(p string, wf filepath.WalkFunc) error

	// Remove removes the named file or (empty) directory.
	Remove(name string) error

	// RemoveAll removes path and any children it contains. It removes everything it can but returns the first error it encounters. If the path does not exist, RemoveAll returns nil (no error).
	RemoveAll(path string) error
}

func Wrap

func Wrap(parent, with Pkger) Pkger

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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