本文整理汇总了Golang中github.com/rminnich/go9p.SrvReq.RespondRwstat方法的典型用法代码示例。如果您正苦于以下问题:Golang SrvReq.RespondRwstat方法的具体用法?Golang SrvReq.RespondRwstat怎么用?Golang SrvReq.RespondRwstat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/rminnich/go9p.SrvReq
的用法示例。
在下文中一共展示了SrvReq.RespondRwstat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Wstat
func (*NopSrv) Wstat(req *go9p.SrvReq) {
// log.Printf("wstat: %p", req)
// req.RespondError(errors.New("wstat: ..."))
req.RespondRwstat()
}
示例2: Wstat
//.........这里部分代码省略.........
if dir.Mode != 0xFFFFFFFF {
mode := dir.Mode & 0777
if req.Conn.Dotu {
if dir.Mode&go9p.DMSETUID > 0 {
mode |= syscall.S_ISUID
}
if dir.Mode&go9p.DMSETGID > 0 {
mode |= syscall.S_ISGID
}
}
err := os.Chmod(aux.path, os.FileMode(mode))
if err != nil {
req.RespondError(toError(err))
return
}
}
uid, gid := go9p.NOUID, go9p.NOUID
if req.Conn.Dotu {
uid = dir.Uidnum
gid = dir.Gidnum
}
// Try to find local uid, gid by name.
if (dir.Uid != "" || dir.Gid != "") && !req.Conn.Dotu {
var err error
uid, err = lookupUser(dir.Uid)
if err != nil {
req.RespondError(err)
return
}
gid, err = lookupGroup(dir.Gid)
if err != nil {
req.RespondError(err)
return
}
}
if uid != go9p.NOUID || gid != go9p.NOUID {
err := os.Chown(aux.path, int(uid), int(gid))
if err != nil {
req.RespondError(toError(err))
return
}
}
if dir.Name != "" {
// if first char is / it is relative to root, else relative to cwd.
var destpath string
if dir.Name[0] == '/' {
destpath = path.Join(fs.path, dir.Name)
fmt.Printf("/ results in %s\n", destpath)
} else {
auxdir, _ := path.Split(aux.path)
destpath = path.Join(auxdir, dir.Name)
fmt.Printf("rel results in %s\n", destpath)
}
err := syscall.Rename(aux.path, destpath)
fmt.Printf("rename %s to %s gets %v\n", aux.path, destpath, err)
if err != nil {
req.RespondError(toError(err))
return
}
aux.path = destpath
}
// Set file size, if specified.
if dir.Length != 0xFFFFFFFFFFFFFFFF {
if err := os.Truncate(aux.path, int64(dir.Length)); err != nil {
req.RespondError(toError(err))
return
}
}
// If either mtime or atime need to be changed, then we must change both.
if dir.Mtime != ^uint32(0) || dir.Atime != ^uint32(0) {
mtime := time.Unix(int64(dir.Mtime), 0)
atime := time.Unix(int64(dir.Atime), 0)
mtimeChanged := (dir.Mtime == ^uint32(0))
atimeChanged := (dir.Atime == ^uint32(0))
if mtimeChanged || atimeChanged {
st, err := os.Stat(aux.path)
if err != nil {
req.RespondError(toError(err))
return
} else if mtimeChanged {
mtime = st.ModTime()
}
}
if err := os.Chtimes(aux.path, atime, mtime); err != nil {
req.RespondError(toError(err))
return
}
}
req.RespondRwstat()
}