本文整理汇总了Golang中github.com/hanwen/go-fuse/fuse/nodefs.File.Truncate方法的典型用法代码示例。如果您正苦于以下问题:Golang File.Truncate方法的具体用法?Golang File.Truncate怎么用?Golang File.Truncate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/hanwen/go-fuse/fuse/nodefs.File
的用法示例。
在下文中一共展示了File.Truncate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Truncate
func (n *classicNode) Truncate(file nodefs.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
}
示例2: Truncate
func (me *memNode) Truncate(file nodefs.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
}
示例3: Truncate
func (n *pathInode) Truncate(file nodefs.File, size uint64, context *fuse.Context) (code fuse.Status) {
// A file descriptor was passed in AND the filesystem implements the
// operation on the file handle. This the common case for ftruncate.
if file != nil {
code = file.Truncate(size)
if code != fuse.ENOSYS {
return code
}
}
files := n.Inode().Files(fuse.O_ANYWRITE)
for _, f := range files {
// TODO - pass context
code = f.Truncate(size)
if code.Ok() {
return code
}
}
if len(files) == 0 || code == fuse.ENOSYS || code == fuse.EBADF {
code = n.fs.Truncate(n.GetPath(), size, context)
}
return code
}