本文整理匯總了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
}