Exemplo n.º 1
0
// Clone a range between two objects.
func (c *Context) CloneRange(dst string, dstOffset uint64, src string, srcOffset uint64, length uint64) error {
	cdst := C.CString(dst)
	defer C.free(unsafe.Pointer(cdst))
	csrc := C.CString(src)
	defer C.free(unsafe.Pointer(csrc))

	if cerr := C.rados_clone_range(c.ctx, cdst, C.uint64_t(dstOffset), csrc, C.uint64_t(srcOffset), C.size_t(length)); cerr < 0 {
		return radosReturnCodeError(cerr)
	}

	return nil
}
Exemplo n.º 2
0
// Clone clones a length of data from an object given an offest to another object starting at an offset. The source
// and destination objects must be on the same PG. This requires that a locator key must be set first.
func (o *Object) Clone(target *Object, srcOffset, dstOffset, length uint64) error {
	srcOid := C.CString(o.name)
	dstOid := C.CString(target.name)

	defer freeString(srcOid)
	defer freeString(dstOid)

	so := C.uint64_t(srcOffset)
	do := C.uint64_t(dstOffset)

	ln := C.size_t(length)

	ret := C.rados_clone_range(o.ioContext, dstOid, do, srcOid, so, ln)
	if err := toRadosError(ret); err != nil {
		err.Message = fmt.Sprintf("Unable to clone %s to %s.", o.name, target.name)
		return err
	}
	return nil
}