-
Notifications
You must be signed in to change notification settings - Fork 18
/
file.go
44 lines (38 loc) · 1.47 KB
/
file.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package styx
import (
"os"
"aqwari.net/net/styx/internal/styxfile"
)
type file struct {
rwc styxfile.Interface
name string
// This is an afid, used for authentication
auth bool
}
// The styx package will attempt to determine the ownership of a file by
// asking the host operating system, if it is a real file. If a given type
// implements the OwnerInfo interface, the styx package will use the methods
// therein to determine file ownership. Uid should return the user name of
// a file's owner. Gid should return the primary group of the file. Muid,
// if implemented, should return the name of the user who last modified the
// file. If Muid is not implemented, the styx package will always return
// the owner of the file for its Muid.
//
// Usage of this interface is opportunistic; a type can implement all or
// some of the methods.
type OwnerInfo interface {
Uid() string
Gid() string
Muid() string
}
// In the 9P protocol, a directory is simply a file that returns zero or more
// styxproto.Stat structures when read. Types that implement the Directory
// interface can avoid marshalling styxproto.Stat methods in the Read methods.
// The Readdir method should return up to n os.FileInfo values, based on the
// contents of the given directory. Further calls to Readdir should pick up where
// the previous call left off.
//
// If n <= 0, Readdir should return os.FileInfo values for all files in the directory.
type Directory interface {
Readdir(n int) ([]os.FileInfo, error)
}