fs

package
Version: v0.0.0-...-ca7265f Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2015 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ClosedFileError       = errors.New("File: Writing on closed file.")
	ReadOnlyFileSystemErr = errors.New("this is a read-only filesystem")
)
View Source
var MemoryFileNotFound = errors.New("File not found")

Functions

This section is empty.

Types

type BaseFile

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

func (*BaseFile) GetFilename

func (f *BaseFile) GetFilename() string

GetFilename returns the filename from the File

func (*BaseFile) IsClosed

func (f *BaseFile) IsClosed() bool

IsClosed returns if te file is closed

type Client

type Client interface {
	Create(filename string) (File, error)
	Open(filename string) (File, error)
	Stat(filename string) (FileInfo, error)
}

type File

type File interface {
	GetFilename() string
	io.Writer
	io.Reader
	io.Closer
}

type FileInfo

type FileInfo os.FileInfo

type MemoryClient

type MemoryClient struct {
	Files map[string]*MemoryFile
	// contains filtered or unexported fields
}

MemoryClient a very convenient client based on memory files, for tests, mocks and some other use cases

func NewMemoryClient

func NewMemoryClient() *MemoryClient

NewMemoryClient returns a new MemoryClient

func (*MemoryClient) Create

func (c *MemoryClient) Create(filename string) (File, error)

Create creates a new MemoryFile, this file will remain on Files map until be closed and purged

func (*MemoryClient) Open

func (c *MemoryClient) Open(filename string) (File, error)

func (*MemoryClient) Purge

func (c *MemoryClient) Purge()

Purge remove all files closed from Files map

func (*MemoryClient) Stat

func (c *MemoryClient) Stat(filename string) (FileInfo, error)

type MemoryFile

type MemoryFile struct {
	Content *bytes.Buffer
	BaseFile
}

func (*MemoryFile) Close

func (f *MemoryFile) Close() error

Close prevents more writes on this file

func (*MemoryFile) Open

func (f *MemoryFile) Open() error

func (*MemoryFile) Read

func (f *MemoryFile) Read(p []byte) (int, error)

Write appends the contents of p to the File

func (*MemoryFile) Write

func (f *MemoryFile) Write(p []byte) (int, error)

Write appends the contents of p to the File

type MemoryFileInfo

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

func (*MemoryFileInfo) IsDir

func (*MemoryFileInfo) IsDir() bool

IsDir always return false

func (*MemoryFileInfo) ModTime

func (*MemoryFileInfo) ModTime() time.Time

ModTime return modification time

func (*MemoryFileInfo) Mode

func (fi *MemoryFileInfo) Mode() os.FileMode

Mode return a null FileMode

func (*MemoryFileInfo) Name

func (fi *MemoryFileInfo) Name() string

Name return the file name

func (*MemoryFileInfo) Size

func (fi *MemoryFileInfo) Size() int64

Size return the file size

func (*MemoryFileInfo) Sys

func (*MemoryFileInfo) Sys() interface{}

Sys return nil always

type OSClient

type OSClient struct {
	Direct  bool
	RootDir string
}

OSClient a filesystem based on OSClient

func NewOSClient

func NewOSClient(rootDir string, direct bool) *OSClient

NewOSClient returns a new OSClient

func (*OSClient) Create

func (c *OSClient) Create(filename string) (File, error)

Create creates a new OSFile

func (*OSClient) Open

func (c *OSClient) Open(filename string) (File, error)

Open opens a new OSFile

func (*OSClient) Stat

func (c *OSClient) Stat(filename string) (FileInfo, error)

type OSFile

type OSFile struct {
	BaseFile
	// contains filtered or unexported fields
}

func (*OSFile) Close

func (f *OSFile) Close() error

func (*OSFile) Read

func (f *OSFile) Read(p []byte) (int, error)

func (*OSFile) Write

func (f *OSFile) Write(p []byte) (int, error)

type SeaweedFSClient

type SeaweedFSClient struct {
	RootDir string
	// contains filtered or unexported fields
}

func NewSeaweedFSClient

func NewSeaweedFSClient(server, rootDir string) *SeaweedFSClient

NewSeaweedFSClient returns a new SeaweedFSClient

func (*SeaweedFSClient) Create

func (c *SeaweedFSClient) Create(filename string) (File, error)

Create creates a new SeaweedFSFile

func (*SeaweedFSClient) Open

func (c *SeaweedFSClient) Open(filename string) (File, error)

Open opens a new SeaweedFSFile

func (*SeaweedFSClient) Stat

func (c *SeaweedFSClient) Stat(filename string) (FileInfo, error)

type SeaweedFSFile

type SeaweedFSFile struct {
	BaseFile
	// contains filtered or unexported fields
}

func (*SeaweedFSFile) Close

func (f *SeaweedFSFile) Close() error

func (*SeaweedFSFile) Read

func (f *SeaweedFSFile) Read(p []byte) (int, error)

func (*SeaweedFSFile) Write

func (f *SeaweedFSFile) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL