pkger/pkging/file.go

45 lines
2.2 KiB
Go
Raw Normal View History

2019-09-02 01:02:45 +03:00
package pkging
2019-09-01 00:00:24 +03:00
import (
"net/http"
"os"
2019-12-03 23:07:51 +03:00
"github.com/gobuffalo/here"
2019-09-01 00:00:24 +03:00
)
type File interface {
2019-10-16 23:09:17 +03:00
// Close closes the File, rendering it unusable for I/O.
2019-09-01 00:00:24 +03:00
Close() error
2019-10-16 23:09:17 +03:00
// Info returns the here.Info of the file
2019-09-01 00:00:24 +03:00
Info() here.Info
2019-10-16 23:09:17 +03:00
// Name retuns the name of the file
2019-09-01 00:00:24 +03:00
Name() string
2019-10-16 23:09:17 +03:00
// 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.
2019-09-01 00:00:24 +03:00
Open(name string) (http.File, error)
2019-10-16 23:09:17 +03:00
// Path returns the here.Path of the file
2019-10-09 20:21:54 +03:00
Path() here.Path
2019-10-16 23:09:17 +03:00
// 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.
2019-09-01 00:00:24 +03:00
Read(p []byte) (int, error)
2019-10-16 23:09:17 +03:00
// 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.
2019-09-01 00:00:24 +03:00
Readdir(count int) ([]os.FileInfo, error)
2019-10-16 23:09:17 +03:00
// 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.
2019-09-01 00:00:24 +03:00
Seek(offset int64, whence int) (int64, error)
2019-10-16 23:09:17 +03:00
// Stat returns the FileInfo structure describing file. If there is an error, it will be of type *PathError.
2019-09-01 00:00:24 +03:00
Stat() (os.FileInfo, error)
2019-10-16 23:09:17 +03:00
// 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).
2019-09-01 00:00:24 +03:00
Write(b []byte) (int, error)
}