files

package
v0.4.9 Latest Latest
Warning

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

Go to latest
Published: May 12, 2017 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotDirectory = errors.New("Couldn't call NextFile(), this isn't a directory")
	ErrNotReader    = errors.New("This file is a directory, can't use Reader functions")
)

Functions

func IsHidden added in v0.3.6

func IsHidden(f File) bool

Types

type File

type File interface {
	// Files implement ReadCloser, but can only be read from or closed if
	// they are not directories
	io.ReadCloser

	// FileName returns a filename associated with this file
	FileName() string

	// FullPath returns the full path used when adding this file
	FullPath() string

	// IsDirectory returns true if the File is a directory (and therefore
	// supports calling `NextFile`) and false if the File is a normal file
	// (and therefor supports calling `Read` and `Close`)
	IsDirectory() bool

	// NextFile returns the next child file available (if the File is a
	// directory). It will return (nil, io.EOF) if no more files are
	// available. If the file is a regular file (not a directory), NextFile
	// will return a non-nil error.
	NextFile() (File, error)
}

File is an interface that provides functionality for handling files/directories as values that can be supplied to commands. For directories, child files are accessed serially by calling `NextFile()`.

func NewFileFromPart

func NewFileFromPart(part *multipart.Part) (File, error)

func NewLinkFile added in v0.3.8

func NewLinkFile(name, path, target string, stat os.FileInfo) File

func NewSerialFile

func NewSerialFile(name, path string, hidden bool, stat os.FileInfo) (File, error)

type FileInfo added in v0.4.5

type FileInfo interface {
	AbsPath() string
	Stat() os.FileInfo
}

type MultipartFile

type MultipartFile struct {
	File

	Part      *multipart.Part
	Reader    *multipart.Reader
	Mediatype string
}

MultipartFile implements File, and is created from a `multipart.Part`. It can be either a directory or file (checked by calling `IsDirectory()`).

func (*MultipartFile) Close

func (f *MultipartFile) Close() error

func (*MultipartFile) FileName

func (f *MultipartFile) FileName() string

func (*MultipartFile) FullPath added in v0.3.8

func (f *MultipartFile) FullPath() string

func (*MultipartFile) IsDirectory

func (f *MultipartFile) IsDirectory() bool

func (*MultipartFile) NextFile

func (f *MultipartFile) NextFile() (File, error)

func (*MultipartFile) Read

func (f *MultipartFile) Read(p []byte) (int, error)

type PeekFile

type PeekFile interface {
	SizeFile

	Peek(n int) File
	Length() int
}

type ReaderFile

type ReaderFile struct {
	// contains filtered or unexported fields
}

ReaderFile is a implementation of File created from an `io.Reader`. ReaderFiles are never directories, and can be read from and closed.

func NewReaderFile

func NewReaderFile(filename, path string, reader io.ReadCloser, stat os.FileInfo) *ReaderFile

func NewReaderPathFile added in v0.4.7

func NewReaderPathFile(filename, path string, reader io.ReadCloser, stat os.FileInfo) (*ReaderFile, error)

func (*ReaderFile) AbsPath added in v0.4.7

func (f *ReaderFile) AbsPath() string

func (*ReaderFile) Close

func (f *ReaderFile) Close() error

func (*ReaderFile) FileName

func (f *ReaderFile) FileName() string

func (*ReaderFile) FullPath added in v0.3.8

func (f *ReaderFile) FullPath() string

func (*ReaderFile) IsDirectory

func (f *ReaderFile) IsDirectory() bool

func (*ReaderFile) NextFile

func (f *ReaderFile) NextFile() (File, error)

func (*ReaderFile) Read

func (f *ReaderFile) Read(p []byte) (int, error)

func (*ReaderFile) Size

func (f *ReaderFile) Size() (int64, error)

func (*ReaderFile) Stat

func (f *ReaderFile) Stat() os.FileInfo

type SizeFile

type SizeFile interface {
	File

	Size() (int64, error)
}

type SliceFile

type SliceFile struct {
	// contains filtered or unexported fields
}

SliceFile implements File, and provides simple directory handling. It contains children files, and is created from a `[]File`. SliceFiles are always directories, and can't be read from or closed.

func NewSliceFile

func NewSliceFile(filename, path string, files []File) *SliceFile

func (*SliceFile) Close

func (f *SliceFile) Close() error

func (*SliceFile) FileName

func (f *SliceFile) FileName() string

func (*SliceFile) FullPath added in v0.3.8

func (f *SliceFile) FullPath() string

func (*SliceFile) IsDirectory

func (f *SliceFile) IsDirectory() bool

func (*SliceFile) Length

func (f *SliceFile) Length() int

func (*SliceFile) NextFile

func (f *SliceFile) NextFile() (File, error)

func (*SliceFile) Peek

func (f *SliceFile) Peek(n int) File

func (*SliceFile) Read

func (f *SliceFile) Read(p []byte) (int, error)

func (*SliceFile) Size

func (f *SliceFile) Size() (int64, error)

type StatFile

type StatFile interface {
	File

	Stat() os.FileInfo
}
type Symlink struct {
	Target string
	// contains filtered or unexported fields
}

func (*Symlink) Close added in v0.3.8

func (f *Symlink) Close() error

func (*Symlink) FileName added in v0.3.8

func (f *Symlink) FileName() string

func (*Symlink) FullPath added in v0.3.8

func (f *Symlink) FullPath() string

func (*Symlink) IsDirectory added in v0.3.8

func (lf *Symlink) IsDirectory() bool

func (*Symlink) NextFile added in v0.3.8

func (lf *Symlink) NextFile() (File, error)

func (*Symlink) Read added in v0.3.8

func (f *Symlink) Read(b []byte) (int, error)

Jump to

Keyboard shortcuts

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