Exemplo n.º 1
0
// NewPatcher creates a Patcher (which basically is a Job object with some hidden extra data).
//
// delta is a reader that provides the delta.
// basis provides the basis file.
func NewPatcher(delta io.Reader, basis io.ReaderAt) (job *Patcher, err error) {
	_job, e := newJob(delta)
	if e != nil {
		err = e
		return
	}

	job = &Patcher{
		Job:   _job,
		basis: basis}

	job.job = C.rs_patch_begin((*C.rs_copy_cb)(unsafe.Pointer(&patch_callback)), unsafe.Pointer(job))
	if job.job == nil {
		job.Close()
		return nil, errors.New("rs_patch_begin failed")
	}

	return
}
Exemplo n.º 2
0
// NewPatcher creates a Patcher (which basically is a Job object with some hidden extra data).
//
// delta is a reader that provides the delta.
// basis provides the basis file.
func NewPatcher(delta io.Reader, basis io.ReaderAt) (job *Patcher, err error) {
	_job, e := newJob(delta)
	if e != nil {
		err = e
		return
	}

	job = &Patcher{
		Job:   _job,
		basis: basis}

	id := uintptr(unsafe.Pointer(_job.rsbufs)) // this is a unique, unchanging number (C doesn't change pointers under the hood)
	storePatcher(job, id)
	job.job = C.rs_patch_begin((*C.rs_copy_cb)(patchCallback), unsafe.Pointer(id))
	if job.job == nil {
		dropPatcher(id)
		job.Close()
		return nil, errors.New("rs_patch_begin failed")
	}

	return
}