filesystem

package
v0.0.0-...-bf4a537 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2018 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NullID represents the nil value of object identifiers
	NullID = ID("-1")

	// RootID is the object identifier of the root of the filesystem
	RootID = ID("/")
)

Variables

View Source
var ErrInvalidObjectID = errors.New("invalid ID")

ErrInvalidObjectID is returned by ParseObjectID for invalid input

Functions

This section is empty.

Types

type Config

type Config struct {
	// Root of the filesystem, a.k.a. directory to serve
	Root string `json:"path"`
}

Config holds the configuration parameters

type FileItem

type FileItem struct {
	FilePath string
	ModTime  time.Time
	// contains filtered or unexported fields
}

func ItemFromInfo

func ItemFromInfo(filePath string, fi os.FileInfo) FileItem

func ItemFromPath

func ItemFromPath(filePath string) (item FileItem, err error)

func (FileItem) IsFresh

func (i FileItem) IsFresh() bool

type Filesystem

type Filesystem struct {
	// contains filtered or unexported fields
}

Filesystem is the main entry point

func New

func New(conf Config) (fs *Filesystem, err error)

New creates a new Filesystem based on the passed configuration

func (*Filesystem) Get

func (fs *Filesystem) Get(id ID) (ret *Object, err error)

func (*Filesystem) LastModTime

func (fs *Filesystem) LastModTime() time.Time

type ID

type ID string

ID is an "opaque" identifier for filesystem objects

func ParseObjectID

func ParseObjectID(s string) (ID, error)

ParseObjectID parses an ID out of a string

func (ID) BaseName

func (id ID) BaseName() string

func (ID) ChildID

func (id ID) ChildID(name string) ID

func (ID) IsNull

func (id ID) IsNull() bool

func (ID) IsRoot

func (id ID) IsRoot() bool

func (ID) ParentID

func (id ID) ParentID() ID

func (ID) String

func (id ID) String() string

type Object

type Object struct {
	ID ID
	FileItem

	Name  string
	IsDir bool
	Size  int64

	ChildrenID []ID
}

Object represents either an item or a container of the content directory

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL