Exemple #1
0
// PathType returns DataObjType, CollectionType, or -1 (error) for the iRODS path specified
func (con *Connection) PathType(p string) (int, error) {
	var (
		err        *C.char
		statResult *C.rodsObjStat_t
	)

	path := C.CString(p)
	defer C.free(unsafe.Pointer(path))

	ccon := con.GetCcon()
	defer con.ReturnCcon(ccon)
	defer C.freeRodsObjStat(statResult)

	if status := C.gorods_stat_dataobject(path, &statResult, ccon, &err); status != 0 {
		return -1, newError(Fatal, fmt.Sprintf("iRODS Stat Failed: %v, %v", p, C.GoString(err)))
	}

	if statResult.objType == C.DATA_OBJ_T {
		return DataObjType, nil
	} else if statResult.objType == C.COLL_OBJ_T {
		return CollectionType, nil
	}

	return -1, newError(Fatal, "Unknown type")

}
Exemple #2
0
// Stat returns a map (key/value pairs) of the system meta information. The following keys can be used with the map:
//
// "objSize"
//
// "dataMode"
//
// "dataId"
//
// "chksum"
//
// "ownerName"
//
// "ownerZone"
//
// "createTime"
//
// "modifyTime"
func (col *Collection) Stat() (map[string]interface{}, error) {

	var (
		err        *C.char
		statResult *C.rodsObjStat_t
	)

	path := C.CString(col.path)

	defer C.free(unsafe.Pointer(path))

	ccon := col.con.GetCcon()
	defer col.con.ReturnCcon(ccon)

	if status := C.gorods_stat_dataobject(path, &statResult, ccon, &err); status != 0 {
		return nil, newError(Fatal, fmt.Sprintf("iRODS Stat Failed: %v, %v", col.path, C.GoString(err)))
	}

	result := make(map[string]interface{})

	result["objSize"] = int(statResult.objSize)
	result["dataMode"] = int(statResult.dataMode)

	result["dataId"] = C.GoString(&statResult.dataId[0])
	result["chksum"] = C.GoString(&statResult.chksum[0])
	result["ownerName"] = C.GoString(&statResult.ownerName[0])
	result["ownerZone"] = C.GoString(&statResult.ownerZone[0])
	result["createTime"] = C.GoString(&statResult.createTime[0])
	result["modifyTime"] = C.GoString(&statResult.modifyTime[0])
	//result["rescHier"] = C.GoString(&statResult.rescHier[0])

	C.freeRodsObjStat(statResult)

	return result, nil
}