Documentation ¶
Index ¶
- func Filter(path, pattern string, filter func([]os.FileInfo, string) []os.FileInfo) ([]os.FileInfo, error)
- func MatchPattern(es []os.FileInfo, pattern string) []os.FileInfo
- func SaveToFile(bytes []byte, dir string) error
- func SetLogger(logger *logrus.Logger)
- type ContentType
- type Filer
- type Sfile
- func (fi *Sfile) BuildFilePath(dir string, filename string) (filePath string, err error)
- func (fi *Sfile) CleanDir(dir string) error
- func (fi *Sfile) CloseFile(f *os.File) error
- func (fi *Sfile) CreateFile(name string) (*os.File, error)
- func (fi *Sfile) DetermineContentType(filePath string) (contentType ContentType, err error)
- func (fi *Sfile) Mkdir(name string, perm os.FileMode) error
- func (fi *Sfile) MkdirAll(path string, perm os.FileMode) error
- func (fi *Sfile) ReadArchive(filename string) ([]byte, error)
- func (fi *Sfile) ReadFile(filename string) ([]byte, error)
- func (fi *Sfile) RemoveAll(path string) error
- func (fi *Sfile) WriteFile(f *os.File, buf []byte) (n int, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Filter ¶
func Filter(path, pattern string, filter func([]os.FileInfo, string) []os.FileInfo) ([]os.FileInfo, error)
Filter files by a name pattern.
func MatchPattern ¶
MatchPattern matches filename to pattern
Types ¶
type ContentType ¶
type ContentType int
ContentType request type.
const ( // UnknownType unarchived content UnknownType ContentType = iota // ZipType application/zip ZipType // GzipType application/x-gzip GzipType // XrarType application/x-rar-compressed XrarType // WebmType video/webm WebmType // TtcfType font/collection TtcfType // OtfType font/otf OtfType // WoffType font/woff WoffType // Woff2Type font/woff2 Woff2Type // WasmType application/wasm WasmType // TtfType font/ttf TtfType )
func (ContentType) String ¶
func (s ContentType) String() string
type Filer ¶
type Filer interface { CreateFile(name string) (*os.File, error) CloseFile(f *os.File) error WriteFile(f *os.File, b []byte) (n int, err error) ReadFile(filename string) ([]byte, error) ReadArchive(filename string) ([]byte, error) DetermineContentType(filePath string) (contentType ContentType, err error) BuildFilePath(dir string, filename string) (filePath string, err error) Mkdir(name string, perm os.FileMode) error CleanDir(dir string) error RemoveAll(path string) error MkdirAll(path string, perm os.FileMode) error }
Filer sends requests to the endpoint.
type Sfile ¶
type Sfile struct { Filer Filer // contains filtered or unexported fields }
Sfile - Filer interface implementation.
func (*Sfile) BuildFilePath ¶
BuildFilePath builds file path using directory and filename.
func (*Sfile) CreateFile ¶
CreateFile calls os.Create to create the file.
func (*Sfile) DetermineContentType ¶
func (fi *Sfile) DetermineContentType(filePath string) (contentType ContentType, err error)
DetermineContentType determines file type.
func (*Sfile) ReadArchive ¶
ReadArchive calls io.ReadArchive to read the file named by filename.
Click to show internal directories.
Click to hide internal directories.