chroot

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: CC0-1.0, CC0-1.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilIterator = errors.New("illegal nil iterator")
)

Errors

Functions

This section is empty.

Types

type Client

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

Client is an implementation of fs with changed root directory.

func New

func New(ctx context.Context, S fs.Interface, baseDir string) (*Client, error)

New returns an implementation of fs with root directory equal to baseDir on S.

func (*Client) Close

func (c *Client) Close() error

Close closes the client.

func (*Client) Copy

func (c *Client) Copy(ctx context.Context, dst string, src string) (int64, error)

Copy copies the contents of the file at src on c to dst on c. If src does not exist or is not a file, then errors.NotFile is returned. If dst's parent directory does not exist, an errors.NotExist error is returned; if the parent exists but is not a directory then an errors.NotDirectory error is returned; an errors.Exist error is returned if a file or directory with path dst already exists. Returns the number of bytes copied.

func (*Client) CopyTo

func (c *Client) CopyTo(ctx context.Context, p string, r io.Reader) (int64, error)

CopyTo copies the contents of r to p on c. If p's parent directory does not exist, an errors.NotExist error is returned; if the parent exists but is not a directory then an errors.NotDirectory error is returned; an errors.Exist error is returned if a file or directory with path p already exists. Returns the number of bytes copied.

func (*Client) Dir

func (c *Client) Dir(ctx context.Context, p string) (fs.DirIterator, error)

Dir returns an iterator containing metadata for the files and directories within the directory with path p. If the path p does not exist then an fs/errors.NotExist error is returned; if the path p exists but is not a directory then an fs/errors.NotDirectory error will be returned. It is the caller's responsibility to call Close on the returned fs.DirIterator, otherwise resources may leak.

func (*Client) Download

func (c *Client) Download(ctx context.Context, p string) (fs.Reader, error)

Download returns a Reader reading from contents of the file with the path p. If no file with path p exists, an fs/errors.NotFile is returned. It is the caller's responsibility to call Close on the returned Reader, otherwise resources may leak.

func (*Client) DownloadMetadata

func (c *Client) DownloadMetadata(ctx context.Context, p string) (*fs.Metadata, error)

DownloadMetadata returns the metadata for the file or directory with the path p. If a file or directory with this path does not exist, an fs/errors.NotExist error is returned.

func (*Client) Exists

func (c *Client) Exists(ctx context.Context, p string) (bool, error)

Exists returns true if and only if path p exists on c.

func (*Client) IsFile

func (c *Client) IsFile(ctx context.Context, p string) (bool, error)

IsFile returns true if and only if path p exists on c and is a file.

func (*Client) Mkdir

func (c *Client) Mkdir(ctx context.Context, p string) error

Mkdir creates the directory with the path p. If p's parent directory does not exist, an fs/errors.NotExist error is returned; if the parent exists but is not a directory then an fs/errors.NotDirectory error is returned; if a file or directory with that path already exists then an fs/errors.Exist error is returned.

func (*Client) Remove

func (c *Client) Remove(ctx context.Context, p string) error

Remove attempts to remove the file or directory with the path p. If the path does not exist, an fs/errors.NotExist error is returned. If the path is a directory and is non-empty or is "/", an fs/errors.DirNotEmpty error is returned.

func (*Client) RemoveFile

func (c *Client) RemoveFile(ctx context.Context, p string) error

RemoveFile attempts to delete the file with path p on c. If p does not exist or is not a file, then the error errors.NotFile will be returned.

func (*Client) ReplaceFile

func (c *Client) ReplaceFile(ctx context.Context, p string) (fs.Writer, error)

ReplaceFile attempts to create or replace the file with path p on c. If p's parent directory does not exist, an errors.NotExist error is returned; if the parent exists but is not a directory then an errors.NotDirectory error is returned; if p exists but is not a file, then the error errors.NotFile will be returned. It is the caller's responsibility to call Close on the returned Writer, otherwise resources may leak.

func (*Client) Upload

func (c *Client) Upload(ctx context.Context, p string) (fs.Writer, error)

Upload returns a Writer writing to the path p. If p's parent directory does not exist, an fs/errors.NotExist error is returned; if the parent exists but is not a directory then an fs/errors.NotDirectory error is returned; if a file or directory with path p already exists then an fs/errors.Exist error is returned. It is the caller's responsibility to call Close on the returned Writer, otherwise resources may leak.

Jump to

Keyboard shortcuts

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