示例#1
0
文件: fs.go 项目: xushiwei/go-mtpfs
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
}
示例#2
0
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
}