本文整理匯總了Golang中clive/zx.RWTree.Wstat方法的典型用法代碼示例。如果您正苦於以下問題:Golang RWTree.Wstat方法的具體用法?Golang RWTree.Wstat怎麽用?Golang RWTree.Wstat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類clive/zx.RWTree
的用法示例。
在下文中一共展示了RWTree.Wstat方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: applyMeta
func (ch Chg) applyMeta(lfs zx.RWTree) error {
nd := ch.D.UsrAttrs()
for _, k := range ignoredPutAttrs {
delete(nd, k)
}
ec := lfs.Wstat(ch.D["path"], nd)
return <-ec
}
示例2: MkZXChgs2
// Make some changes in the test zx tree, another version.
// - Remove /2
// - Create /2/n2
// - Truncate /1
func MkZXChgs2(t Fataler, fs zx.RWTree) {
if err := <-fs.Remove("/2"); err != nil {
t.Fatalf("rm: %s", err)
}
<-fs.Mkdir("/2", zx.Dir{"mode": "0750"})
if err := <-fs.Mkdir("/2/n2", zx.Dir{"mode": "0750"}); err != nil {
t.Fatalf("mkdir: %s", err)
}
TouchZX(fs, "/2/n2")
TouchZX(fs, "/2")
if err := <-fs.Wstat("/1", zx.Dir{"size": "50"}); err != nil {
t.Fatalf("truncate: %s", err)
}
TouchZX(fs, "/1")
}
示例3: MkZXChgs
// Make some changes in the test zx tree.
// - Touch /a/a1
// - Chmod /a/a2
// - Remove /a/b/c /a/b/c/c3
// - Create /a/n /a/n/m /a/n/m/m1
func MkZXChgs(t Fataler, fs zx.RWTree) {
TouchZX(fs, "/a/a1")
if err := <- fs.Wstat("/a/a2", zx.Dir{"mode": "0750"}); err != nil {
t.Fatalf("chmod: %s", err)
}
if err := <-fs.RemoveAll("/a/b/c"); err != nil {
t.Fatalf("rm: %s", err)
}
<-fs.Mkdir("/a", zx.Dir{"mode": "0750"})
<-fs.Mkdir("/a/n", zx.Dir{"mode": "0750"})
if err := <-fs.Mkdir("/a/n/m", zx.Dir{"mode": "0750"}); err != nil {
t.Fatalf("mkdir: %s", err)
}
err := zx.PutAll(fs, "/a/n/m/m1", zx.Dir{"mode": "0640"}, []byte("a new file\n"))
if err != nil {
t.Fatalf("new file: %s", err)
}
TouchZX(fs, "/a/n/m/m1")
TouchZX(fs, "/a/n/m")
TouchZX(fs, "/a/n")
TouchZX(fs, "/a")
}
示例4: ugo
// see if fn has errors (permissions) or not for the given path and 1,2,4 perm. bit.
// returns xxxxxxxxxxxx where x is y or n
// for ugo and masks 777 770 700 000
// Expected result is always yyyyynynnnnn
func ugo(t Fataler, fs zx.RWTree, p string, bit uint, fn func(zx.RWTree) error) string {
err := <-fs.Wstat(p, zx.Dir{"mode": "0777"})
if err != nil {
t.Fatalf("wstat: %s", err)
}
defer func() {
// so we can later remove it
<-fs.Wstat(p, zx.Dir{"mode": "0755"})
}()
// /chkd is nemo gid1
usrs := []usr{
usr{who: "uid", ai: &auth.Info{Uid: dbg.Usr, SpeaksFor: dbg.Usr, Ok: true,
Gids: map[string]bool{}}},
usr{who: "gid", ai: &auth.Info{Uid: "gid1", SpeaksFor: dbg.Usr, Ok: true,
Gids: map[string]bool{}}},
usr{who: "oid", ai: &auth.Info{Uid: "other", SpeaksFor: dbg.Usr, Ok: true,
Gids: map[string]bool{}}},
}
shift := uint(0)
m := uint(0777)
out := ""
for i := 0; i < 4; i++ {
printf("mode %o\n", m)
err := <-fs.Wstat(p, zx.Dir{"mode": fmt.Sprintf("0%o", m)})
if err != nil {
t.Fatalf("wstat: %s", err)
}
for _, u := range usrs {
if err := fn(authfor(t, fs, u.ai)); err != nil {
out += "n"
printf("%s can't for %o\n", u.who, m)
} else {
out += "y"
printf("%s can for %o\n", u.who, m)
}
}
m &^= (bit << shift)
shift += 3
}
return out
}
示例5: TouchZX
// set a fake mtime that can be predicted.
func TouchZX(fs zx.RWTree, path string) error {
d := zx.Dir{}
d.SetTime("mtime", time.Unix(xt/1e9, xt%1e9))
xt += 1e9
return <-fs.Wstat(path, d)
}
示例6: rwstat
func rwstat(t Fataler, fs zx.RWTree, fname string) {
<-fs.Wstat(fname, zx.Dir{"mode": "0700", "Foo": "Bar"})
}