Documentation
¶
Overview ¶
Package fs implements blob store structures for representing files and directories.
Index ¶
- Variables
- type Dir
- func (d *Dir) Add(ctx context.Context, store bs.Store, path string) (bs.Ref, error)
- func (d *Dir) AddDir(ctx context.Context, store bs.Store, path string) (bs.Ref, error)
- func (d *Dir) Dirent(ctx context.Context, g bs.Getter, name string) (*Dirent, error)
- func (d *Dir) Each(ctx context.Context, g bs.Getter, f func(string, *Dirent) error) error
- func (d *Dir) Find(ctx context.Context, g bs.Getter, path string) (*Dirent, error)
- func (d *Dir) Load(ctx context.Context, g bs.Getter, ref bs.Ref) error
- func (d *Dir) Ref() (bs.Ref, error)
- func (d *Dir) Set(ctx context.Context, store bs.Store, name string, dirent *Dirent) (bs.Ref, schema.Outcome, error)
- type Dirent
- func (*Dirent) Descriptor() ([]byte, []int)deprecated
- func (d *Dirent) Dir(ctx context.Context, g bs.Getter) (*Dir, error)
- func (x *Dirent) GetItem() string
- func (x *Dirent) GetMode() uint32
- func (d *Dirent) IsDir() bool
- func (d *Dirent) IsLink() bool
- func (*Dirent) ProtoMessage()
- func (x *Dirent) ProtoReflect() protoreflect.Message
- func (x *Dirent) Reset()
- func (d *Dirent) Size(ctx context.Context, g bs.Getter) (int64, error)
- func (x *Dirent) String() string
- type FS
Constants ¶
This section is empty.
Variables ¶
var File_fs_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type Dir ¶
Dir is a directory of files, symlinks, and subdirs. It is implemented as a schema.Map, with each key the name of the entry and each payload a serialized Dirent.
func (*Dir) Add ¶
Add adds the file, symlink, or dir at path to d. If path is a dir, this is recursive. It returns the possibly-updated Ref for d.
func (*Dir) Dirent ¶
Dirent finds the entry in d with the given name. It returns nil if no such entry exists. It does not traverse subdirs, and name must not be a multi-segment path. For that, use Find. Note: Dirent does not understand "." and "..".
func (*Dir) Each ¶
Each calls a callback on each name/Dirent pair in d (in an indeterminate order). If the callback returns an error, Each exits with that error.
func (*Dir) Find ¶
Find resolves a path starting at d, traversing into subdirs as appropriate, and returning the entry found at the end of path. It does not resolve symlinks in its traversal. Leading path separators in `path` are ignored; traversal is always relative to d. Note: Find does not understand "." and "..".
func (*Dir) Set ¶
func (d *Dir) Set(ctx context.Context, store bs.Store, name string, dirent *Dirent) (bs.Ref, schema.Outcome, error)
Set sets the given name in d to the given Dirent. It returns the possibly updated Ref of d and the schema.Outcome resulting from the underlying "bs/schema".Map.Set call.
type Dirent ¶
type Dirent struct { Mode uint32 `protobuf:"varint,1,opt,name=mode,proto3" json:"mode,omitempty"` // If mode indicates this is a Dir, // then item is the hex ref of a serialized Dir (i.e., a schema.Map). // If it's a symlink, // then item is simply the target path. // If it's a plain file, // then item is the hex ref of the root of a split.Write tree of its contents. Item string `protobuf:"bytes,2,opt,name=item,proto3" json:"item,omitempty"` // contains filtered or unexported fields }
func (*Dirent) Descriptor
deprecated
func (*Dirent) Dir ¶
Dir returns the directory referred to by d. It is an error to call this when !d.IsDir().
func (*Dirent) IsLink ¶
IsLink tells whether d refers to a symlink. If it does, then d.Item is the target of the link.
func (*Dirent) ProtoMessage ¶
func (*Dirent) ProtoMessage()
func (*Dirent) ProtoReflect ¶
func (x *Dirent) ProtoReflect() protoreflect.Message
type FS ¶
FS implements io/fs.FS.
func NewFS ¶
NewFS created a new *FS reading from the given bs.Getter and rooted at the given ref. The given context object is stored in the FS and used in subsequent calls to Open, Stat, ReadDir, etc. This is an antipattern but acceptable when an object must adhere to a context-free stdlib interface (https://github.com/golang/go/wiki/CodeReviewComments#contexts). Callers may replace the context object during the lifetime of the FS as needed.
func (*FS) Open ¶
Open opens the file at the given path in FS.
TODO: This presently handles only plain files, but should handle directories and symlinks as well.
TODO: Symlinks in the given path should be traversed but are not at the moment.