當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Req.RespondRwalk方法代碼示例

本文整理匯總了Golang中github.com/lionkov/go9p/p/srv.Req.RespondRwalk方法的典型用法代碼示例。如果您正苦於以下問題:Golang Req.RespondRwalk方法的具體用法?Golang Req.RespondRwalk怎麽用?Golang Req.RespondRwalk使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/lionkov/go9p/p/srv.Req的用法示例。


在下文中一共展示了Req.RespondRwalk方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Walk

func (*Ufs) Walk(req *srv.Req) {
	fid := req.Fid.Aux.(*Fid)
	tc := req.Tc

	err := fid.stat()
	if err != nil {
		req.RespondError(err)
		return
	}

	if req.Newfid.Aux == nil {
		req.Newfid.Aux = new(Fid)
	}

	nfid := req.Newfid.Aux.(*Fid)
	wqids := make([]p.Qid, len(tc.Wname))
	path := fid.path
	i := 0
	for ; i < len(tc.Wname); i++ {
		p := path + "/" + tc.Wname[i]
		st, err := os.Lstat(p)
		if err != nil {
			if i == 0 {
				req.RespondError(Enoent)
				return
			}

			break
		}

		wqids[i] = *dir2Qid(st)
		path = p
	}

	nfid.path = path
	req.RespondRwalk(wqids[0:i])
}
開發者ID:rjkroege,項目名稱:go9p,代碼行數:37,代碼來源:ufs.go

示例2: Walk

// BUG(mbucc) does not fully implement spec when fid = newfid.
// From http://plan9.bell-labs.com/magic/man2html/5/walk:
//	If newfid is the same as fid, the above discussion applies, with the
//	obvious difference that if the walk changes the state of newfid, it
//	also changes the state of fid; and if newfid is unaffected, then fid
//	is also unaffected.
//
func (u *VuFs) Walk(req *srv.Req) {
	fid := req.Fid.Aux.(*Fid)
	tc := req.Tc

	_, err := os.Stat(fid.path)
	if err != nil {
		req.RespondError(toError(err))
		return
	}

	if req.Newfid.Aux == nil {
		req.Newfid.Aux = new(Fid)
	}

	newfid := req.Newfid.Aux.(*Fid)
	wqids := make([]p.Qid, len(tc.Wname))
	path := fid.path
	i := 0

	// Ensure execute permission on the walk root.
	st, err := os.Stat(path)
	if err != nil {
		req.RespondError(srv.Enoent)
		return
	}
	f, err := dir2Dir(path, st, req.Conn.Srv.Upool)
	if err != nil {
		req.RespondError(toError(err))
		return
	}
	if !CheckPerm(f, req.Fid.User, p.DMEXEC) {
		req.RespondError(srv.Eperm)
		return
	}

	for ; i < len(tc.Wname); i++ {

		var newpath string

		// Don't allow client to dotdot out of the file system root.
		if tc.Wname[i] == ".." {
			if path == u.Root {
				continue
			} else {
				newpath = path[:strings.LastIndex(path, "/")]
				if newpath == u.Root {
					continue
				}
			}
		} else {
			newpath = path + "/" + tc.Wname[i]
		}

		st, err := os.Stat(newpath)
		if err != nil {
			if i == 0 {
				req.RespondError(srv.Enoent)
				return
			}

			break
		}

		wqids[i] = *dir2Qid(st)

		if (wqids[i].Type & p.QTDIR) > 0 {
			f, err := dir2Dir(newpath, st, req.Conn.Srv.Upool)
			if err != nil {
				req.RespondError(toError(err))
				return
			}
			if !CheckPerm(f, req.Fid.User, p.DMEXEC) {
				req.RespondError(srv.Eperm)
				return
			}
		}

		path = newpath
	}

	newfid.path = path
	req.RespondRwalk(wqids[0:i])
}
開發者ID:postfix,項目名稱:vufs,代碼行數:90,代碼來源:vufs.go


注:本文中的github.com/lionkov/go9p/p/srv.Req.RespondRwalk方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。