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