fs

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2018 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package fs provides helpers to implement 9p objects: directories and files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dir

type Dir struct {
	*stat.Reader
	// contains filtered or unexported fields
}

Dir implements a directory.

func NewDir

func NewDir(s stat.Stat, children []Entry) *Dir

NewDir creates a new Dir ready for use.

The stat and child entries are expected to be prepared by the caller. Children will have their parent set to this Dir.

func (*Dir) Open

func (d *Dir) Open() error

Open prepares the dir for access.

Internally, a stat.Reader is prepared from the contents of the children.

func (*Dir) Parent

func (d *Dir) Parent() Entry

Parent returns the parent of this dir, which may be nil if it is the root.

func (*Dir) Qid

func (d *Dir) Qid() qid.Qid

Qid returns the qid of this dir.

func (*Dir) Stat

func (d *Dir) Stat() stat.Stat

Stat returns the stat of this dir.

func (*Dir) Walk

func (d *Dir) Walk(wname string) (Entry, error)

Walk to a child, the parent, or itself.

wname is either the name of a child, "..", or "". If it is the name of a child, the respective entry is returned. For ".." the parent, or the dir itself (if it is the root) is returned. When wname is the empty string, the dir itself is returned.

type Entry

type Entry interface {
	Parent() Entry              // Parent returns this objects parent, it may be nil for the root object.
	Qid() qid.Qid               // Qid returns this files qid.
	Stat() stat.Stat            // Stat returns this files stat.
	Open() error                // Open prepares this file for access.
	Walk(string) (Entry, error) // Walk to a child or itself.
	io.ReadSeeker               // All files and directories need this.
}

Entry is the general interface for 9p objects.

type File

type File struct {

	// this is the minimal interface we need, as a 9p read can also seek
	io.ReadSeeker
	// contains filtered or unexported fields
}

File implements a file.

func NewFile

func NewFile(s stat.Stat, rs io.ReadSeeker) *File

NewFile prepares a new File ready for use.

The stat and ReadSeeker are expected to be prepared by the caller.

func (*File) Open

func (f *File) Open() error

Open the file for access.

This is a nop here and to be overriden by embedders.

func (*File) Parent

func (f *File) Parent() Entry

Parent returns the parent.

func (*File) Qid

func (f *File) Qid() qid.Qid

Qid returns the qid.

func (*File) Stat

func (f *File) Stat() stat.Stat

Stat returns the stat.

func (*File) Walk

func (f *File) Walk(wname string) (Entry, error)

Walk can only walk to itself for plain files.

It is used for the side effect of creating another fid for this file.

Jump to

Keyboard shortcuts

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