readerfile.go 584 Bytes
Newer Older
1 2 3 4 5 6 7 8
package files

import "io"

// ReaderFile is a implementation of File created from an `io.Reader`.
// ReaderFiles are never directories, and can be read from and closed.
type ReaderFile struct {
	Filename string
9
	Reader   io.ReadCloser
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
}

func (f *ReaderFile) IsDirectory() bool {
	return false
}

func (f *ReaderFile) NextFile() (File, error) {
	return nil, ErrNotDirectory
}

func (f *ReaderFile) FileName() string {
	return f.Filename
}

func (f *ReaderFile) Read(p []byte) (int, error) {
	return f.Reader.Read(p)
}

func (f *ReaderFile) Close() error {
29
	return f.Reader.Close()
30
}