spacefs

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReadMode = FileHandlerMode(0)
	WriteMode
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateDirEntry

type CreateDirEntry struct {
	Path string
	Mode os.FileMode
}

type DirEntryAttribute

type DirEntryAttribute interface {
	Name() string       // base name of the file
	Size() uint64       // length in bytes for files; can be anything for directories
	Mode() os.FileMode  // file mode bits
	Uid() string        // user id of owner of entry
	Gid() string        // group id of owner of entry
	Ctime() time.Time   // creation time
	ModTime() time.Time // modification time
	IsDir() bool
}

DirEntryAttribute similar to the FileInfo in the os.Package

type DirEntryOps

type DirEntryOps interface {
	// Path should return the absolute path string for directory or file
	// Directory path's should end in `/`
	Path() string
	// Attribute should return the metadata information for the file
	Attribute() (DirEntryAttribute, error)
}

DirEntryOps are the list of actions to be invoked on a directry entry A directory entry is either a file or a folder. See DirOps and FileOps for operations specific to those types

type DirOps

type DirOps interface {
	DirEntryOps
	ReadDir(ctx context.Context) ([]DirEntryOps, error)
}

DirOps are the list of actions that can be done on a directory

type FSOps

type FSOps interface {
	// Root should return the root directory entry
	Root(ctx context.Context) (DirEntryOps, error)
	// LookupPath should return the directory entry at that particular path
	LookupPath(ctx context.Context, path string) (DirEntryOps, error)
	// Open a file at specific path, with specified mode
	Open(ctx context.Context, path string, mode FileHandlerMode) (FileHandler, error)
	// CreateEntry should create an directory entry and return either a FileOps or DirOps entry
	// depending on the mode
	CreateEntry(ctx context.Context, req CreateDirEntry) (DirEntryOps, error)
}

FSOps represents the filesystem operations

type FileHandler

type FileHandler interface {
	Read(ctx context.Context, data []byte, offset int64) (int, error)
	Write(ctx context.Context, data []byte, offset int64) (int, error)
	Close(ctx context.Context) error
}

FileHandler is in charge of reading, writing and closing access to a file It should handle locking and track read and write offsets till it is closed

type FileHandlerMode

type FileHandlerMode uint8

type FileOps

type FileOps interface {
	DirEntryOps
	Open(ctx context.Context, mode FileHandlerMode) (FileHandler, error)
}

FileOps are the list of actions that can be done on a file

type SpaceDirectory

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

SpaceDirectory is a directory managed by space

func (*SpaceDirectory) Attribute

func (dir *SpaceDirectory) Attribute() (DirEntryAttribute, error)

Attribute implements DirEntryOps Attribute() and fetches the metadata of the directory

func (*SpaceDirectory) Path

func (dir *SpaceDirectory) Path() string

Path implements DirEntryOps Path() and return the path of the directory

func (*SpaceDirectory) ReadDir

func (dir *SpaceDirectory) ReadDir(ctx context.Context) ([]DirEntryOps, error)

ReadDir implements DirOps ReadDir and returns the list of entries in a directory

type SpaceFS

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

SpaceFS is represents the filesystem that FUSE Interacts with It implements the FSOps interface And is responsible for managing file access, encryption and decryption

func New

func New(store fsds.FSDataSource) (*SpaceFS, error)

New initializes a SpaceFS instance using store as it source of informatioin

func (*SpaceFS) CreateEntry

func (fs *SpaceFS) CreateEntry(ctx context.Context, req CreateDirEntry) (DirEntryOps, error)

func (*SpaceFS) LookupPath

func (fs *SpaceFS) LookupPath(ctx context.Context, path string) (DirEntryOps, error)

LookupPath implements the FsOps interface for looking up information in a directory

func (*SpaceFS) Open

func (fs *SpaceFS) Open(ctx context.Context, path string, mode FileHandlerMode) (FileHandler, error)

Open a file at specified path

func (*SpaceFS) Root

func (fs *SpaceFS) Root(ctx context.Context) (DirEntryOps, error)

Root implements the FSOps Root function It returns the root directory of the file

type SpaceFile

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

SpaceFile is a file managed by space

func (*SpaceFile) Attribute

func (f *SpaceFile) Attribute() (DirEntryAttribute, error)

Attribute implements DirEntryOps Attribute() and fetches the metadata of the directory

func (*SpaceFile) Open

func (f *SpaceFile) Open(ctx context.Context, mode FileHandlerMode) (FileHandler, error)

Open implements FileOps Open It should download/cache the content of the file and return a fileHandler that can read the cached content.

func (*SpaceFile) Path

func (f *SpaceFile) Path() string

Path implements DirEntryOps Path() and return the path of the directory

Jump to

Keyboard shortcuts

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