1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
### -------------------------------------------------------------------------
### TODO: Get rid of this or move it somewhere else.
### A lower-level version of h5vc::getSampleData() that doesn't mangle the
### data.
get_attrs <- function(filename, group)
{
f <- H5Fopen(filename, flags="H5F_ACC_RDONLY")
on.exit(H5Fclose(f))
g <- H5Gopen(f, group)
on.exit(H5Gclose(g), add=TRUE)
num_attrs <- H5Oget_num_attrs(g)
attrs <- unlist(
lapply(seq_len(num_attrs),
function(i)
{
A <- H5Aopen_by_idx(g, n=i-1L)
attrname <- H5Aget_name(A)
attrval <- H5Aread(A)
H5Aclose(A)
setNames(list(attrval), attrname)
}
),
recursive=FALSE
)
as.data.frame(attrs)
}
|