### -------------------------------------------------------------------------

### 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)
}

