Documentation ¶
Overview ¶
Package fs is an abstraction for needed filesystem operations.
Index ¶
- Constants
- Variables
- type FilesystemObject
- func (fso *FilesystemObject) Clean() error
- func (fso *FilesystemObject) Delete() error
- func (fso *FilesystemObject) DetectContentType() error
- func (fso *FilesystemObject) GetAllFiles() []*FilesystemObject
- func (fso *FilesystemObject) IsEqual(path string, size int64, modTime time.Time) bool
- func (fso *FilesystemObject) Open() (*os.File, error)
- func (fso *FilesystemObject) Scan() error
- type Registry
- type WebObject
Constants ¶
const (
PathKey = "path"
)
Variables ¶
var ( // ErrIsDir communicates that we didn't expect a directory. ErrIsDir = errors.New("file is a directory") // ErrIsNotDir communicates that we expected a directory. ErrIsNotDir = errors.New("file is not directory") // ErrDirNotEmpty communicates that the directory isn't empty. ErrDirNotEmpty = errors.New("directory not empty") // ErrIsNotFile communicates that the operation only works on normal files. ErrIsNotFile = errors.New("file is not a normal file") )
Functions ¶
This section is empty.
Types ¶
type FilesystemObject ¶
type FilesystemObject struct { Path string `json:"path"` ContentType string `json:"content_type"` Size int64 `json:"size"` ModTime time.Time `json:"mod_time"` IsDir bool `json:"is_dir"` Mode os.FileMode `json:"-"` Root bool `json:"-"` Children []*FilesystemObject `json:"-"` sync.Mutex // contains filtered or unexported fields }
FilesystemObject is a representation of a filesystem object.
func NewFSObj ¶
func NewFSObj(path string, info os.FileInfo, root bool, logger *zap.Logger) (*FilesystemObject, error)
NewFSObj create a new FileSystemObject
func ObjFromPath ¶
ObjFromPath stats a path and creates a FilesystemObject from it.
func (*FilesystemObject) Clean ¶
func (fso *FilesystemObject) Clean() error
Clean cleans out all empty directories under the FSO.
func (*FilesystemObject) Delete ¶
func (fso *FilesystemObject) Delete() error
func (*FilesystemObject) DetectContentType ¶
func (fso *FilesystemObject) DetectContentType() error
DetectContentType detects the mimetype of
func (*FilesystemObject) GetAllFiles ¶
func (fso *FilesystemObject) GetAllFiles() []*FilesystemObject
GetAllFiles gets all files in the children of the FilesystemObject
func (*FilesystemObject) IsEqual ¶
IsEqual deterimines if the FSO is the same as on disk. Just a quick check to see if the checsum needs to be updated.
func (*FilesystemObject) Scan ¶
func (fso *FilesystemObject) Scan() error
Scan recursively scans the directory and populates its children.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is a struct that keeps track of what paths we serve.
func NewRegistry ¶
NewRegistry returns a new Register instance.
func (*Registry) GetAllFiles ¶
GetAllFiles simply returns a list of all files of all registered roots.
type WebObject ¶
type WebObject struct { *FilesystemObject // WebPath is where the file is downloadable. WebPath string `json:"web_path"` }
WebObject wraps a FSO, to add a webpath.