Documentation
¶
Index ¶
- Variables
- type File
- type MultipartFile
- type PeekFile
- type ReaderFile
- type SizeFile
- type SliceFile
- func (f *SliceFile) Close() error
- func (f *SliceFile) FileName() string
- func (f *SliceFile) IsDirectory() bool
- func (f *SliceFile) Length() int
- func (f *SliceFile) NextFile() (File, error)
- func (f *SliceFile) Peek(n int) File
- func (f *SliceFile) Read(p []byte) (int, error)
- func (f *SliceFile) Size() (int64, error)
- type StatFile
Constants ¶
This section is empty.
Variables ¶
var (
ErrNotDirectory = errors.New("Couln't call NextFile(), this isn't a directory")
ErrNotReader = errors.New("This file is a directory, can't use Reader functions")
)
Functions ¶
This section is empty.
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 full filename path associated with this file
FileName() 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 NewSerialFile ¶
func NewSerialFile(path string, file *os.File) (File, error)
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) IsDirectory ¶
func (f *MultipartFile) IsDirectory() bool
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 string, reader io.ReadCloser, stat os.FileInfo) *ReaderFile
func (*ReaderFile) IsDirectory ¶
func (f *ReaderFile) IsDirectory() bool
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 string, files []File) *SliceFile
func (*SliceFile) IsDirectory ¶
func (f *SliceFile) IsDirectory() bool