Changeset 6f53da8


Ignore:
Timestamp:
Dec 29, 2021, 5:52:03 PM (2 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/crepe
Children:
1c2ccea
Parents:
1666945
git-author:
Paul Brossier <piem@piem.org> (01/29/19 04:06:41)
git-committer:
Paul Brossier <piem@piem.org> (12/29/21 17:52:03)
Message:

[file_hdf5] add list routine

Location:
src/io
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/io/file_hdf5.c

    r1666945 r6f53da8  
    3636#endif
    3737
     38#define MAX_DEPTH 100
     39
    3840struct _aubio_file_hdf5_t {
    3941  const char_t *path;
     
    4951  if (f->fid <= 0) goto failure;
    5052
     53  // TODO keep a copy
    5154  f->path = path;
     55
     56  //AUBIO_DBG("file_hdf5: opened %s\n", f->path);
     57  //aubio_file_hdf5_list(f);
     58
    5259  return f;
    5360
     
    121128}
    122129
     130static herr_t aubio_file_hdf5_iterate(hid_t loc_id, const char *name,
     131    const H5L_info_t *info UNUSED, void *opdata)
     132{
     133  H5O_info_t infobuf;
     134  const char_t *type_name;
     135  uint_t *depth = (uint_t *)opdata;
     136  herr_t err = H5Oget_info_by_name(loc_id, name, &infobuf, H5P_DEFAULT);
     137  if (err < 0) goto failure;
     138  if (*depth > MAX_DEPTH) goto failure;
     139  switch (infobuf.type) {
     140    case H5O_TYPE_GROUP:
     141      type_name = "group";
     142      break;
     143    case H5O_TYPE_DATASET:
     144      type_name = "dataset";
     145      break;
     146    case H5O_TYPE_NAMED_DATATYPE:
     147      type_name = "datatype";
     148      break;
     149    default:
     150      type_name = "unknown";
     151      break;
     152  }
     153  AUBIO_MSG("%*s %s (%s)\n", *depth, "-", name, type_name);
     154  if (infobuf.type == H5O_TYPE_GROUP) {
     155    uint_t d = *depth + 1;
     156    err = H5Literate_by_name(loc_id, name, H5_INDEX_NAME, H5_ITER_NATIVE,
     157        NULL, aubio_file_hdf5_iterate, &d, H5P_DEFAULT);
     158  }
     159failure:
     160  return err;
     161}
     162
     163void aubio_file_hdf5_list(aubio_file_hdf5_t *f)
     164{
     165  uint_t depth = 1;
     166  herr_t err = H5Literate(f->fid, H5_INDEX_NAME, H5_ITER_NATIVE,
     167      NULL, aubio_file_hdf5_iterate, &depth);
     168  if (err < 0)
     169    AUBIO_ERR("file_hdf5: failed iterating into %s\n", f->path);
     170}
     171
    123172void del_aubio_file_hdf5(aubio_file_hdf5_t *f)
    124173{
  • src/io/file_hdf5.h

    r1666945 r6f53da8  
    2828void del_aubio_file_hdf5(aubio_file_hdf5_t *f);
    2929
     30void aubio_file_hdf5_list(aubio_file_hdf5_t *f);
     31
    3032uint_t aubio_file_hdf5_load_dataset_into_tensor (aubio_file_hdf5_t *f,
    3133    const char_t *key, aubio_tensor_t *tensor);
Note: See TracChangeset for help on using the changeset viewer.