本文整理汇总了Golang中github.com/hanwen/go-fuse/fuse/nodefs.File.GetAttr方法的典型用法代码示例。如果您正苦于以下问题:Golang File.GetAttr方法的具体用法?Golang File.GetAttr怎么用?Golang File.GetAttr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/hanwen/go-fuse/fuse/nodefs.File
的用法示例。
在下文中一共展示了File.GetAttr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetAttr
func (n *pathInode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Context) (code fuse.Status) {
var fi *fuse.Attr
if file == nil {
// called on a deleted files.
file = n.Inode().AnyFile()
}
if file != nil {
code = file.GetAttr(out)
}
if file == nil || code == fuse.ENOSYS || code == fuse.EBADF {
fi, code = n.fs.GetAttr(n.GetPath(), context)
}
if fi != nil {
n.setClientInode(fi.Ino)
}
if fi != nil && !fi.IsDir() && fi.Nlink == 0 {
fi.Nlink = 1
}
if fi != nil {
*out = *fi
}
return code
}
示例2: GetAttr
func (me *memNode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Context) (code fuse.Status) {
var sz uint64
if file != nil {
code := file.GetAttr(out)
if code.Ok() {
sz = out.Size
} else {
msg := fmt.Sprintf("File.GetAttr(%s) = %v, %v", file.String(), out, code)
panic(msg)
}
}
me.mutex.RLock()
defer me.mutex.RUnlock()
*out = me.info
if file != nil {
out.Size = sz
}
return fuse.OK
}
示例3: GetAttr
// GetAttr - FUSE call
func (rfs *ReverseFS) GetAttr(relPath string, context *fuse.Context) (*fuse.Attr, fuse.Status) {
if rfs.isTranslatedConfig(relPath) {
return rfs.inoAwareStat(configfile.ConfReverseName)
}
// Handle virtual files
var f nodefs.File
var status fuse.Status
virtual := false
if rfs.isDirIV(relPath) {
virtual = true
f, status = rfs.newDirIVFile(relPath)
}
if rfs.isNameFile(relPath) {
virtual = true
f, status = rfs.newNameFile(relPath)
}
if virtual {
if !status.Ok() {
fmt.Printf("GetAttr %q: newXFile failed: %v\n", relPath, status)
return nil, status
}
var a fuse.Attr
status = f.GetAttr(&a)
return &a, status
}
cPath, err := rfs.decryptPath(relPath)
if err != nil {
return nil, fuse.ToStatus(err)
}
a, status := rfs.inoAwareStat(cPath)
if !status.Ok() {
return nil, status
}
// Calculate encrypted file size
if a.IsRegular() {
a.Size = rfs.contentEnc.PlainSizeToCipherSize(a.Size)
}
return a, fuse.OK
}