本文整理匯總了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)
}