Check external link before actual access

Hi all,

I'd link to check a node exists before traversing it.
This node, child of a group G, is an external link.
Here's a tree example output using h5dump:

HDF5 "sqnz_unstruct_2dom_TOP.hdf" {
FILE_CONTENTS {
  group /
  group /base1
  dataset /base1/ data
  group /base1/dom1
  dataset /base1/dom1/ file
  ext link /base1/dom1/ link -> sqnz_unstruct_2dom_dom1_SUB.hdf /base1/dom1
  dataset /base1/dom1/ path
  group /base1/dom2
  dataset /base1/dom2/ file
  ext link /base1/dom2/ link -> sqnz_unstruct_2dom_dom2_SUB.hdf /base1/dom2
  dataset /base1/dom2/ path
   }
}

I just want to test that ' link' is there, I *don't* want the lib to traverse it.

Using H5Oget_info, I cannot check if it's an external link.
Using H5Lexists, I cannot stop the traversal to the actual linked-to node,
which fail if link prefix property is not set.

We used to do that with H5Gget_objinfo which is said to be obsolete...

Any idea ?

-MP-

···

-----------------------------------------------------------------------
  Marc POINOT [ONERA/DSNA] Tel:+33.1.46.73.42.84 Fax:+33.1.46.73.41.66
  Avertissement/disclaimer http://www.onera.fr/onera-en/emails-terms

Hi Marc,

You could use H5Literate with the following iterator:

herr_t findExternalLink(hid_t g_id, const char * name, const H5L_info_t * info, void * op_data)
{
     if (info->type == H5L_TYPE_EXTERNAL && !strcmp(name, (char *)op_data))
    {
         return 1;
    }

     return 0;
}

And you call it with:
int idx = 0;
char * nameToFind = "foo";
err = H5Literate(obj_id, H5_INDEX_NAME, H5_ITER_INC, &idx, findExternalLink, nameToFind);

Regards

Calixte

···

On 21/09/2012 11:50, Marc Poinot wrote:

Hi all,

I'd link to check a node exists before traversing it.
This node, child of a group G, is an external link.
Here's a tree example output using h5dump:

HDF5 "sqnz_unstruct_2dom_TOP.hdf" {
FILE_CONTENTS {
group /
group /base1
dataset /base1/ data
group /base1/dom1
dataset /base1/dom1/ file
ext link /base1/dom1/ link -> sqnz_unstruct_2dom_dom1_SUB.hdf /base1/dom1
dataset /base1/dom1/ path
group /base1/dom2
dataset /base1/dom2/ file
ext link /base1/dom2/ link -> sqnz_unstruct_2dom_dom2_SUB.hdf /base1/dom2
dataset /base1/dom2/ path
  }
}

I just want to test that ' link' is there, I *don't* want the lib to traverse it.

Using H5Oget_info, I cannot check if it's an external link.
Using H5Lexists, I cannot stop the traversal to the actual linked-to node,
which fail if link prefix property is not set.

We used to do that with H5Gget_objinfo which is said to be obsolete...

Any idea ?

-MP-
-----------------------------------------------------------------------
Marc POINOT [ONERA/DSNA] Tel:+33.1.46.73.42.84 Fax:+33.1.46.73.41.66
Avertissement/disclaimer E-mails sent from ONERA | ONERA

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

--
Calixte Denizet
Software Development Engineer
-----------------------------------------------------------
Scilab Enterprises
143bis rue Yves Le Coz - 78000 Versailles, France
http://www.scilab-enterprises.com

Calixte Denizet wrote:

  Hi Marc,

You could use H5Literate with the following iterator:

works nice, thanks for the quick answer.

···

--
-----------------------------------------------------------------------
  Marc POINOT [ONERA/DSNA] Tel:+33.1.46.73.42.84 Fax:+33.1.46.73.41.66
  Avertissement/disclaimer http://www.onera.fr/onera-en/emails-terms