本文整理汇总了Golang中code/google/com/p/goplan9/plan9.Fcall.Type方法的典型用法代码示例。如果您正苦于以下问题:Golang Fcall.Type方法的具体用法?Golang Fcall.Type怎么用?Golang Fcall.Type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类code/google/com/p/goplan9/plan9.Fcall
的用法示例。
在下文中一共展示了Fcall.Type方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: attach
func (c *ClientConn) attach(fc *plan9.Fcall) *plan9.Fcall {
fc.Type = plan9.Rattach
fc.Iounit = c.iounit
fref, _ := c.createFileRef(c.explorer.Root(), FTDIR, 0)
fc.Qid = fref.Qid
c.bindFid(fc.Fid, fc.Qid.Path)
return fc
}
示例2: walk
func (c *ClientConn) walk(fc *plan9.Fcall) *plan9.Fcall {
fc.Type = plan9.Rwalk
fref, has := c.fidRef(fc.Fid)
if !has {
return c.invalidFidErr(fc)
}
if _, has := c.fidRef(fc.Newfid); has {
return c.fidUsedErr(fc)
}
current := fref.Path
for idx, name := range fc.Wname {
var ft FileType
if current == 0 {
return c.fileNotFoundErr(fc)
}
if ff, ok := c.explorer.(FileFinder); ok {
f, err := ff.FindInDir(current, name)
if err != nil {
return c.unexpectedErr(fc, err)
}
current = f.Path
} else {
childs, err := c.explorer.ListDir(current)
if err != nil {
return c.unexpectedErr(fc, err)
}
idx, have := childs.FindExact(name)
if !have {
return c.fileNotFoundErr(fc)
}
current = childs[idx].Path
}
ref, err := c.createFileRef(current, ft, 0)
if err != nil {
return c.unexpectedErr(fc, err)
}
fc.Wqid = append(fc.Wqid, ref.Qid)
// if the last match isn't a directory, there is no need to find
// another part of the path
//
// so, just break here
if ft == FTFILE && idx != len(fc.Wname)-1 {
return c.fileNotFoundErr(fc)
}
}
if len(fc.Wqid) == 0 {
// newfid and fid will map to the same file
if fc.Newfid != fc.Fid {
c.bindFid(fc.Newfid, fref.Path)
}
} else {
// make a bind between the last qid and the new fid
c.bindFid(fc.Newfid, fc.Wqid[len(fc.Wqid)-1].Path)
}
return fc
}
示例3: read
func (c *ClientConn) read(fc *plan9.Fcall) *plan9.Fcall {
fc.Type = plan9.Rread
if fref, has := c.fidRef(fc.Fid); has {
if fref.IsDir() {
return c.readdir(fc, fref)
}
return c.readfile(fc, fref)
}
return c.invalidFidErr(fc)
}
示例4: clunk
func (c *ClientConn) clunk(fc *plan9.Fcall) *plan9.Fcall {
fc.Type = plan9.Rclunk
oldpath, had := c.unbindFid(fc.Fid)
if had {
err := c.explorer.Close(oldpath)
if err != nil {
return c.unexpectedErr(fc, err)
}
}
return fc
}
示例5: write
func (c *ClientConn) write(fc *plan9.Fcall) *plan9.Fcall {
fc.Type = plan9.Rwrite
if fref, have := c.fidRef(fc.Fid); have {
n, err := c.explorer.Write(fref.Path, fc.Data, fc.Offset)
if err != nil {
return c.unexpectedErr(fc, err)
}
fc.Count = uint32(n)
return fc
}
return c.invalidFidErr(fc)
}
示例6: open
func (c *ClientConn) open(fc *plan9.Fcall) *plan9.Fcall {
fc.Type = plan9.Ropen
if fref, has := c.fidRef(fc.Fid); has {
err := c.explorer.Open(fref.Path, FileMode(fc.Mode))
if err != nil {
return c.unexpectedErr(fc, err)
}
fc.Iounit = c.iounit
fc.Qid = fref.Qid
return fc
}
return c.invalidFidErr(fc)
}
示例7: create
func (c *ClientConn) create(fc *plan9.Fcall) *plan9.Fcall {
fc.Type = plan9.Rcreate
if fref, have := c.fidRef(fc.Fid); have {
file := File{Name: fc.Name}
file.Type = FileType(fc.Mode)
path, err := c.explorer.Create(fref.Path, file, uint32(fc.Perm))
if err != nil {
return c.unexpectedErr(fc, err)
}
cref, err := c.createFileRef(path, file.Type, 0)
if err != nil {
return c.unexpectedErr(fc, err)
}
fc.Iounit = c.iounit
fc.Qid = cref.Qid
c.unbindFid(fc.Fid)
c.bindFid(fc.Fid, cref.Path)
return fc
}
return c.invalidFidErr(fc)
}
示例8: unexpectedErr
func (c *ClientConn) unexpectedErr(fc *plan9.Fcall, err error) *plan9.Fcall {
fc.Type = plan9.Rerror
fc.Ename = err.Error()
return fc
}
示例9: fidUsedErr
func (c *ClientConn) fidUsedErr(fc *plan9.Fcall) *plan9.Fcall {
fc.Type = plan9.Rerror
fc.Ename = "fid in use"
return fc
}
示例10: fileNotFoundErr
func (c *ClientConn) fileNotFoundErr(fc *plan9.Fcall) *plan9.Fcall {
fc.Type = plan9.Rerror
fc.Ename = "file not found"
return fc
}
示例11: invalidFidErr
func (c *ClientConn) invalidFidErr(fc *plan9.Fcall) *plan9.Fcall {
fc.Type = plan9.Rerror
fc.Ename = "fid not found"
return fc
}
示例12: version
func (c *ClientConn) version(fc *plan9.Fcall) *plan9.Fcall {
fc.Type = plan9.Rversion
fc.Version = "9P2000"
return fc
}
示例13: noauth
func noauth(fc *plan9.Fcall) *plan9.Fcall {
fc.Type = plan9.Rerror
fc.Ename = "no auth requried"
return fc
}