Documentation
¶
Index ¶
- func Register(name string, f func() *rt.Table)
- func WrapConnectFunc(fileStoreName string, ...) func(*rt.Thread, *rt.GoCont) (rt.Cont, error)
- type ConnectFunc
- type Fs
- func (c *Fs) Chdir(ctx context.Context, p string) error
- func (c *Fs) Close() error
- func (c *Fs) Copy(ctx context.Context, src string, dst string) (n int64, err error)
- func (c *Fs) CopyAll(ctx context.Context, src string, dst string) error
- func (c *Fs) Dir(ctx context.Context, p string) (itr fs.DirIterator, err error)
- func (c *Fs) Download(ctx context.Context, p string) (r fs.Reader, err error)
- func (c *Fs) DownloadMetadata(ctx context.Context, p string) (md *fs.Metadata, err error)
- func (c *Fs) Exists(ctx context.Context, p string) (ok bool, err error)
- func (c *Fs) GetTimeout() time.Duration
- func (c *Fs) Getwd() (string, error)
- func (c *Fs) Hash(ctx context.Context, p string, h crypto.Hash) (b []byte, err error)
- func (c *Fs) IsClosed() bool
- func (c *Fs) IsDir(ctx context.Context, p string) (ok bool, err error)
- func (c *Fs) IsDirEmpty(ctx context.Context, p string) (ok bool, err error)
- func (c *Fs) IsFile(ctx context.Context, p string) (ok bool, err error)
- func (c *Fs) Mkdir(ctx context.Context, p string) error
- func (c *Fs) MkdirRecursive(ctx context.Context, p string) error
- func (c *Fs) Remove(ctx context.Context, p string) error
- func (c *Fs) RemoveAll(ctx context.Context, p string) error
- func (c *Fs) RemoveFile(ctx context.Context, p string) error
- func (c *Fs) ReplaceFile(ctx context.Context, p string) (w fs.Writer, err error)
- func (c *Fs) Rmdir(ctx context.Context, p string) error
- func (c *Fs) SetTimeout(timeout time.Duration)
- func (c *Fs) String() string
- func (c *Fs) Upload(ctx context.Context, p string) (w fs.Writer, err error)
- type Reader
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
Register registers the given function that returns a table to be added to the package table using the given name (typically a name of a file store). If a function is already registered with the given name then it will be replaced; if the name coincides with one of the package functions or values then it will be overwritten. Note that any function registered after the package is loaded into the Lua runtime will not appear in that instance of the package.
Types ¶
type ConnectFunc ¶
ConnectFunc defines a function that will connect to a file store.
type Fs ¶
type Fs struct {
// contains filtered or unexported fields
}
Fs wraps an fs.Interface.
func (*Fs) Copy ¶
Copy copies the contents of the file at src in s to dst in s. If src does not exist or is not a file, then errors.NotExist is returned. If dst's parent directory does not exist, an errors.NotExist error is returned; an errors.Exist error is returned if a file or directory with path dst already exists.
func (*Fs) CopyAll ¶
CopyAll recursively copies the file or directory structure rooted at path src to path dst. If src does not exist, then errors.NotExist is returned. If dst's parent directory does not exist, an errors.NotExist error is returned; an errors.Exist error is returned if a file or directory with path dst already exists.
func (*Fs) Dir ¶
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 errors.NotExist error is returned; if the path p exists but is not a directory then an errors.NotDirectory error will be returned.
func (*Fs) Download ¶
Download returns the contents of the file with the path p. It is the caller's responsibility to call Close on the returned io.ReadCloser, otherwise resources may leak.
func (*Fs) DownloadMetadata ¶
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 errors.NotExist error is returned.
func (*Fs) Hash ¶
Hash returns the hash of the file with path p on s, using the hash h. If the hash is not available (as determined by crypto.Hash.Available) then an errors.HashNotAvailable error will be returned. If the path does not exist, or is a directory, an errors.NotExist error is returned.
func (*Fs) IsDirEmpty ¶
IsDirEmpty returns true if and only if path p exists in s and is an empty directory. If the path is not a directory, returns errors.NotDirectory.
func (*Fs) Mkdir ¶
Mkdir creates the directory with the path p. 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 a file or directory with that path already exists then an errors.Exist error is returned.
func (*Fs) MkdirRecursive ¶
MkdirRecursive creates the directory with the given path p, along with any intermediate directories as necessary. An errors.Exist error is returned if a file or directory with that path already exists, or if a file already exists with an intermediate path.
func (*Fs) Remove ¶
Remove attempts to remove the file or directory with the path p. If the path does not exist, an errors.NotExist error is returned. If the path is a directory and is non-empty or is "/", an errors.DirNotEmpty error is returned.
func (*Fs) RemoveAll ¶
RemoveAll removes path p from s if p is a file, and removes p and all its contents from s if p is a directory. If the path does not exist, RemoveAll returns nil (no error).
func (*Fs) RemoveFile ¶
RemoveFile attempts to delete the file with path p in s. If p is not a file, then the error ErrNotFile will be returned.
func (*Fs) ReplaceFile ¶
ReplaceFile attempts to create or replace the file with path p in s. 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 (*Fs) Rmdir ¶
Rmdir removes the path p from s, if p is an empty directory. If the path is not a directory, returns errors.NotDirectory; if the directory is not empty or is "/", returns errors.DirNotEmpty.
func (*Fs) SetTimeout ¶
SetTimeout sets the timeout. A negative timeout is interpreted to mean no timeout.
func (*Fs) Upload ¶
Upload returns a Writer writing to the path p. 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 a file or directory with path p already exists then an errors.Exist error is returned.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader wraps an fs.Reader with a rolling timeout.
func ValueToReader ¶
ValueToReader turns a Lua value to a *Reader if possible.
func (*Reader) GetTimeout ¶
GetTimeout returns the current timeout duration.
func (*Reader) Read ¶
Read reads up to len(p) bytes into p. It returns the number of bytes read and any error encountered.
func (*Reader) SetTimeout ¶
SetTimeout sets the timeout duration.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer wraps an fs.Writer with a rolling timeout.
func ValueToWriter ¶
ValueToWriter turns a Lua value to a *Writer if possible.
func (*Writer) GetTimeout ¶
GetTimeout returns the current timeout duration.
func (*Writer) SetTimeout ¶
SetTimeout sets the timeout duration.