本文整理汇总了Golang中github.com/lionkov/go9p/p/srv.Req.RespondRcreate方法的典型用法代码示例。如果您正苦于以下问题:Golang Req.RespondRcreate方法的具体用法?Golang Req.RespondRcreate怎么用?Golang Req.RespondRcreate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/lionkov/go9p/p/srv.Req
的用法示例。
在下文中一共展示了Req.RespondRcreate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Create
func (*VuFs) Create(req *srv.Req) {
fid := req.Fid.Aux.(*Fid)
tc := req.Tc
st, err := os.Stat(fid.path)
if err != nil {
req.RespondError(toError(err))
return
}
path := fid.path + "/" + tc.Name
var e error = nil
var file *os.File = nil
switch {
case tc.Perm&p.DMDIR != 0:
e = os.Mkdir(path, os.FileMode(tc.Perm&0777))
if e == nil {
file, e = os.OpenFile(path, omode2uflags(tc.Mode), 0)
}
case tc.Perm&p.DMSYMLINK != 0:
case tc.Perm&p.DMLINK != 0:
case tc.Perm&p.DMNAMEDPIPE != 0:
case tc.Perm&p.DMDEVICE != 0:
case tc.Perm&p.DMSOCKET != 0:
case tc.Perm&p.DMSETUID != 0:
case tc.Perm&p.DMSETGID != 0:
req.RespondError(srv.Ebaduse)
return
default:
var mode uint32 = tc.Perm & 0777
file, e = os.OpenFile(path,
omode2uflags(tc.Mode)|os.O_CREATE,
os.FileMode(mode))
}
if e != nil {
req.RespondError(toError(e))
return
}
fid.path = path
fid.file = file
st, err = os.Stat(fid.path)
if err != nil {
req.RespondError(err)
return
}
req.RespondRcreate(dir2Qid(st), 0)
}
示例2: Create
func (*Ufs) Create(req *srv.Req) {
fid := req.Fid.Aux.(*Fid)
tc := req.Tc
err := fid.stat()
if err != nil {
req.RespondError(err)
return
}
path := fid.path + "/" + tc.Name
var e error = nil
var file *os.File = nil
switch {
case tc.Perm&p.DMDIR != 0:
e = os.Mkdir(path, os.FileMode(tc.Perm&0777))
case tc.Perm&p.DMSYMLINK != 0:
e = os.Symlink(tc.Ext, path)
case tc.Perm&p.DMLINK != 0:
n, e := strconv.ParseUint(tc.Ext, 10, 0)
if e != nil {
break
}
ofid := req.Conn.FidGet(uint32(n))
if ofid == nil {
req.RespondError(srv.Eunknownfid)
return
}
e = os.Link(ofid.Aux.(*Fid).path, path)
ofid.DecRef()
case tc.Perm&p.DMNAMEDPIPE != 0:
case tc.Perm&p.DMDEVICE != 0:
req.RespondError(&p.Error{"not implemented", p.EIO})
return
default:
var mode uint32 = tc.Perm & 0777
if req.Conn.Dotu {
if tc.Perm&p.DMSETUID > 0 {
mode |= syscall.S_ISUID
}
if tc.Perm&p.DMSETGID > 0 {
mode |= syscall.S_ISGID
}
}
file, e = os.OpenFile(path, omode2uflags(tc.Mode)|os.O_CREATE, os.FileMode(mode))
}
if file == nil && e == nil {
file, e = os.OpenFile(path, omode2uflags(tc.Mode), 0)
}
if e != nil {
req.RespondError(toError(e))
return
}
fid.path = path
fid.file = file
err = fid.stat()
if err != nil {
req.RespondError(err)
return
}
req.RespondRcreate(dir2Qid(fid.st), 0)
}