本文整理汇总了Golang中github.com/rminnich/go9p.SrvReq.RespondRwalk方法的典型用法代码示例。如果您正苦于以下问题:Golang SrvReq.RespondRwalk方法的具体用法?Golang SrvReq.RespondRwalk怎么用?Golang SrvReq.RespondRwalk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/rminnich/go9p.SrvReq
的用法示例。
在下文中一共展示了SrvReq.RespondRwalk方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Walk
func (sfs *NopSrv) Walk(req *go9p.SrvReq) {
fid := req.Fid.Aux.(Dispatcher)
tc := req.Tc
if sfs.Debuglevel > 0 {
log.Printf("walk %s %s", fid, tc.Wname)
}
if req.Newfid.Aux == nil {
req.Newfid.Aux = fid.Clone()
}
if len(tc.Wname) == 0 {
w := make([]go9p.Qid, 0)
req.RespondRwalk(w)
} else {
nfid, err := fid.Walk(req, tc.Wname[0])
if err != nil {
req.RespondError(toError(err))
return
}
req.Newfid.Aux = nfid
w := []go9p.Qid{*Qid(nfid)}
req.RespondRwalk(w)
}
}
示例2: Walk
func (fs *fileSystem) Walk(req *go9p.SrvReq) {
// Stat the file.
aux := req.Fid.Aux.(*Aux)
if err := aux.stat(); err != nil {
req.RespondError(err)
return
}
// Create a new file handle, if necessary.
if req.Newfid.Aux == nil {
req.Newfid.Aux = &Aux{rootID: aux.rootID}
}
nfid := req.Newfid.Aux.(*Aux)
wqids := make([]go9p.Qid, 0, len(req.Tc.Wname))
newPath := aux.path
// Append actual files after the root.
for i, name := range req.Tc.Wname {
// If we have no root then the first segment is the root ID.
if nfid.rootID == "" {
nfid.rootID = name
if root := (*FileSystem)(fs).Root(nfid.rootID); root == nil {
req.RespondError(go9p.Enoent)
return
}
wqids = append(wqids, *newRootQid(nfid.rootID))
continue
}
// Otherwise we're already walking a root so continue to traverse the files.
p := newPath + "/" + name
st, err := os.Lstat(p)
if err != nil {
if i == 0 {
req.RespondError(go9p.Enoent)
return
}
break
}
wqids = append(wqids, *newQid(st))
newPath = p
}
nfid.path = newPath
req.RespondRwalk(wqids)
}