// Truncate sets the size of the named object in the pool referenced by // the given context to size. If this enlarges the object, the new area // is logically filled with zeroes. If this shrinks the object, the data // is removed. func (c *Context) Truncate(name string, size int64) error { cname := C.CString(name) defer C.free(unsafe.Pointer(cname)) if cerr := C.rados_trunc(c.ctx, cname, C.uint64_t(size)); cerr != 0 { return fmt.Errorf("RADOS trunc: %s: %s", name, strerror(cerr)) } return nil }
// Truncate sets the size of the named object in the pool referenced by // the given context to size. If this enlarges the object, the new area // is logically filled with zeroes. If this shrinks the object, the data // is removed. func (c *Context) Truncate(name string, size int64) error { cname := C.CString(name) defer C.free(unsafe.Pointer(cname)) if cerr := C.rados_trunc(c.ctx, cname, C.uint64_t(size)); cerr != 0 { return radosReturnCodeError(cerr) } return nil }
func (r *RadosIoCtx) Trunc(oid string, length uint64) error { coid := C.CString(oid) defer func() { C.free(unsafe.Pointer(coid)) }() cerr := C.rados_trunc(*r.ctx, coid, C.uint64_t(length)) if cerr < 0 { return errors.New("resize object failed") } return nil }
// Truncate modifies the size of an object. If the object size in increased, the new space is zero-filled. If the size // is reduced, the excess data is removed. func (o *Object) Truncate(size uint64) error { oid := C.CString(o.name) defer freeString(oid) s := C.uint64_t(size) ret := C.rados_trunc(o.ioContext, oid, s) if err := toRadosError(ret); err != nil { err.Message = fmt.Sprintf("Unable to resize object %s to size %d.", o.name, size) return err } return nil }
// Truncate resizes the object with key oid to size size. If the operation // enlarges the object, the new area is logically filled with zeroes. If the // operation shrinks the object, the excess data is removed. It returns an // error, if any. func (p *Pool) Truncate(oid string, size uint64) error { c_oid := C.CString(oid) defer C.free(unsafe.Pointer(c_oid)) ret := C.rados_trunc(p.ioctx, c_oid, (C.uint64_t)(size)) if ret == 0 { return nil } else { return RadosError(int(ret)) } }
// Truncate resizes the object with key oid to size size. If the operation // enlarges the object, the new area is logically filled with zeroes. If the // operation shrinks the object, the excess data is removed. It returns an // error, if any. func (ioctx *IOContext) Truncate(oid string, size uint64) error { c_oid := C.CString(oid) defer C.free(unsafe.Pointer(c_oid)) return GetRadosError(C.rados_trunc(ioctx.ioctx, c_oid, (C.uint64_t)(size))) }