-
Notifications
You must be signed in to change notification settings - Fork 43
/
data_source.go
29 lines (26 loc) · 954 Bytes
/
data_source.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package fsds
import (
"context"
"io"
"os"
)
// ReadSeekCloser implements interfaces to read, copy, seek and close.
type ReadSeekCloser interface {
io.Reader
io.Seeker
io.Writer
io.Closer
}
// FSDataSource is data source of file/directories and their information
// It is used as a local/remote cache for looking up information about the directories.
// It should also ensure that the user in the context has permission to data that is being request
type FSDataSource interface {
// Get a single node
Get(ctx context.Context, path string) (*DirEntry, error)
// GetChildren returns child entries in the file
GetChildren(ctx context.Context, path string) ([]*DirEntry, error)
// OpenReader returns a file reader
Open(ctx context.Context, path string) (ReadSeekCloser, error)
// CreateEntry should create a directory or file based on the mode at the path
CreateEntry(ctx context.Context, path string, mode os.FileMode) (*DirEntry, error)
}