本文整理汇总了Golang中github.com/hanwen/go-fuse/fuse.File类的典型用法代码示例。如果您正苦于以下问题:Golang File类的具体用法?Golang File怎么用?Golang File使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了File类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: GetAttr
func (n *fileNode) GetAttr(file fuse.File, context *fuse.Context) (fi *fuse.Attr, code fuse.Status) {
if file != nil {
return file.GetAttr()
}
a := &fuse.Attr{Mode: fuse.S_IFREG | 0644}
if n.backing != "" {
fi, err := os.Stat(n.backing)
if err != nil {
return nil, fuse.ToStatus(err)
}
a.Size = uint64(fi.Size())
t := n.file.Mtime()
if n.dirty {
t = fi.ModTime()
}
a.SetTimes(&t, &t, &t)
} else if n.file != nil {
a.Size = uint64(n.file.filesize)
t := n.file.Mtime()
a.SetTimes(&t, &t, &t)
}
return a, fuse.OK
}
开发者ID:xushiwei,项目名称:go-mtpfs,代码行数:27,代码来源:fs.go
示例2: GetAttr
func (n *fileNode) GetAttr(out *fuse.Attr, file fuse.File, context *fuse.Context) (code fuse.Status) {
if file != nil {
return file.GetAttr(out)
}
out.Mode = fuse.S_IFREG | 0644
f := n.File()
if n.backing != "" {
fi, err := os.Stat(n.backing)
if err != nil {
return fuse.ToStatus(err)
}
out.Size = uint64(fi.Size())
t := f.Mtime()
if n.dirty {
t = fi.ModTime()
}
out.SetTimes(&t, &t, &t)
} else if f != nil {
out.Size = uint64(f.filesize)
t := f.Mtime()
out.SetTimes(&t, &t, &t)
}
return fuse.OK
}
开发者ID:thomasf,项目名称:go-mtpfs,代码行数:27,代码来源:fs.go
示例3: Truncate
func (n *fileNode) Truncate(file fuse.File, size uint64, context *fuse.Context) (code fuse.Status) {
if file != nil {
return file.Truncate(size)
} else if n.backing != "" {
return fuse.ToStatus(os.Truncate(n.backing, int64(size)))
}
return fuse.OK
}
开发者ID:xushiwei,项目名称:go-mtpfs,代码行数:8,代码来源:fs.go
示例4: Truncate
func (me *memNode) Truncate(file fuse.File, size uint64, context *fuse.Context) (code fuse.Status) {
me.mutex.Lock()
defer me.mutex.Unlock()
me.promote()
if file != nil {
code = file.Truncate(size)
} else {
code = fuse.ToStatus(os.Truncate(me.backing, int64(size)))
}
if code.Ok() {
me.info.Size = size
me.touch()
}
return code
}
开发者ID:janneke,项目名称:termite,代码行数:16,代码来源:memunionfs.go
示例5: putDeletion
func (me *UnionFs) putDeletion(name string) (code fuse.Status) {
marker := me.deletionPath(name)
me.deletionCache.AddEntry(path.Base(marker))
// Is there a WriteStringToFileOrDie ?
writable := me.fileSystems[0]
fi, code := writable.GetAttr(marker)
if code.Ok() && fi.Size == int64(len(name)) {
return fuse.OK
}
var f fuse.File
if code == fuse.ENOENT {
f, code = writable.Create(marker, uint32(os.O_TRUNC|os.O_WRONLY), 0644)
} else {
writable.Chmod(marker, 0644)
f, code = writable.Open(marker, uint32(os.O_TRUNC|os.O_WRONLY))
}
if !code.Ok() {
log.Printf("could not create deletion file %v: %v", marker, code)
return fuse.EPERM
}
defer f.Release()
defer f.Flush()
n, code := f.Write(&fuse.WriteIn{}, []byte(name))
if int(n) != len(name) || !code.Ok() {
panic(fmt.Sprintf("Error for writing %v: %v, %v (exp %v) %v", name, marker, n, len(name), code))
}
return fuse.OK
}
开发者ID:jravasi,项目名称:go-fuse,代码行数:31,代码来源:unionfs.go
示例6: GetAttr
func (me *memNode) GetAttr(file fuse.File, context *fuse.Context) (fi *fuse.Attr, code fuse.Status) {
var sz uint64
if file != nil {
fi, code := file.GetAttr()
if code.Ok() {
sz = fi.Size
} else {
msg := fmt.Sprintf("File.GetAttr(%s) = %v, %v", file.String(), fi, code)
panic(msg)
}
}
me.mutex.RLock()
defer me.mutex.RUnlock()
info := me.info
if file != nil {
info.Size = sz
}
return &info, fuse.OK
}
开发者ID:janneke,项目名称:termite,代码行数:19,代码来源:memunionfs.go
注:本文中的github.com/hanwen/go-fuse/fuse.File类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论