예제 #1
0
파일: ioctx.go 프로젝트: omnicube/go-ceph
// Next retrieves the next object name in the pool/namespace iterator.
// Upon a successful invocation (return value of true), the Value method should
// be used to obtain the name of the retrieved object name. When the iterator is
// exhausted, Next returns false. The Err method should used to verify whether the
// end of the iterator was reached, or the iterator received an error.
//
// Example:
//	iter := pool.Iter()
//	defer iter.Close()
//	for iter.Next() {
//		fmt.Printf("%v\n", iter.Value())
//	}
//	return iter.Err()
//
func (iter *Iter) Next() bool {
	var c_entry *C.char
	if cerr := C.rados_objects_list_next(iter.ctx, &c_entry, nil); cerr < 0 {
		iter.err = GetRadosError(int(cerr))
		return false
	}
	iter.entry = C.GoString(c_entry)
	return true
}
예제 #2
0
파일: rados_io.go 프로젝트: vuleetu/gorados
func (ctx *RadosListCtx) Next() (string, error) {
	var buf *C.char
	cerr := C.rados_objects_list_next(*ctx.list_ctx, &buf, nil)
	if cerr == -C.ENOENT {
		log.Println("Next failed")
		return "", io.EOF
	}
	if cerr < 0 {
		log.Println("Next failed")
		return "", errors.New("next failed")
	}
	//log.Println(C.GoString(buf))
	return C.GoString(buf), nil
}
예제 #3
0
// Next returns the objectId and locationKey (if any) of the next object.
func (ol *ObjectList) Next() (object *Object, locationKey string, err error) {
	var e *C.char
	var k *C.char
	ret := C.rados_objects_list_next(ol.listContext, &e, &k)
	if errs := toRadosError(ret); errs != nil {
		errs.Message = "Unable to get next object from list."
		err = errs
	} else {
		object = &Object{
			ioContext: ol.ioContext,
			name:      C.GoString(e),
		}
		locationKey = C.GoString(k)
	}
	return
}
예제 #4
0
파일: ioctx.go 프로젝트: mittalms/go-ceph
// ListObjects lists all of the objects in the pool associated with the I/O
// context, and called the provided listFn function for each object, passing
// to the function the name of the object.
func (ioctx *IOContext) ListObjects(listFn ObjectListFunc) error {
	var ctx C.rados_list_ctx_t
	ret := C.rados_objects_list_open(ioctx.ioctx, &ctx)
	if ret < 0 {
		return RadosError(ret)
	}
	defer func() { C.rados_objects_list_close(ctx) }()

	for {
		var c_entry *C.char
		ret := C.rados_objects_list_next(ctx, &c_entry, nil)
		if ret == -2 { // FIXME
			return nil
		} else if ret < 0 {
			return RadosError(ret)
		}
		listFn(C.GoString(c_entry))
	}

	panic("invalid state")
}