func (r *RadosIoCtx) Stat(oid string) (*RadosObjectStat, error) { var size C.uint64_t var time_t C.time_t coid := C.CString(oid) defer func() { C.free(unsafe.Pointer(coid)) }() cerr := C.rados_stat(*r.ctx, coid, &size, &time_t) if cerr < 0 { //log.Println("Get object stat failed, error is", C.GoString(C.strerror(-cerr))) return nil, errors.New("Get object stat failed") } return &RadosObjectStat{uint64(size), uint64(C.uint64_t(time_t))}, nil }
// Stat retrieves information about the named object in the pool referenced // by the given context. A pointer to the object is returned as an // os.FileInfo (fulfills FileStat interface). func (c *Context) Stat(name string) (os.FileInfo, error) { var csize C.uint64_t var ctime C.time_t cname := C.CString(name) defer C.free(unsafe.Pointer(cname)) if cerr := C.rados_stat(c.ctx, cname, &csize, &ctime); cerr < 0 { return nil, fmt.Errorf("RADOS stat %s: %s", name, strerror(cerr)) } return &Object{ name: name, size: int64(csize), modTime: time.Unix(int64(ctime), int64(0)), sys: sys{c: c, pool: c.Pool}, }, nil }
// Status returns the status of an object. func (o *Object) Status() (*ObjectStatus, error) { oid := C.CString(o.name) defer freeString(oid) var objectSize C.uint64_t var modifiedTime C.time_t ret := C.rados_stat(o.ioContext, oid, &objectSize, &modifiedTime) if err := toRadosError(ret); err != nil { err.Message = fmt.Sprintf("Unable to get status for object %s.", o.name) return nil, err } return &ObjectStatus{ size: uint64(objectSize), modifiedTime: time.Unix(int64(modifiedTime), 0), }, nil }
// Stat returns the size of the object and its last modification time func (ioctx *IOContext) Stat(object string) (stat ObjectStat, err error) { var c_psize C.uint64_t var c_pmtime C.time_t c_object := C.CString(object) defer C.free(unsafe.Pointer(c_object)) ret := C.rados_stat( ioctx.ioctx, c_object, &c_psize, &c_pmtime) if ret < 0 { return ObjectStat{}, RadosError(int(ret)) } else { return ObjectStat{ Size: uint64(c_psize), ModTime: time.Unix(int64(c_pmtime), 0), }, nil } }