My understanding is that the creation of an objects within a group (such as another group or dataset) is inherently creating a hard link from that group to the other object. So if you passed in that group or dataset name as the "link name" argument to the H5Lget_info function it should return H5L_TYPE_HARD, as you've stated.

If, however, you've explicitly created a soft-link to another group using the H5Lcreate_soft function and passed _that_ name to the H5Lget_info function, the type would be listed as H5L_TYPE_SOFT.
The following documentation helped clarify HDF5 links for me:
http://www.hdfgroup.org/HDF5/doc/UG/UG_frame09Groups.html

The following source code should clarify what I'm trying to say:

#include "hdf5.h"
#include <iostream>
using std::cout;
using std::endl;

void printLinkInfo(H5L_type_t type)
{
 switch (type)
 {
 case H5L_TYPE_HARD:     cout << "H5L_TYPE_HARD";     break;
 case H5L_TYPE_SOFT:     cout << "H5L_TYPE_SOFT";     break;
 case H5L_TYPE_EXTERNAL: cout << "H5L_TYPE_EXTERNAL"; break;
 case H5L_TYPE_ERROR:    cout << "H5L_TYPE_ERROR";    break;
 }
}

int main()
{
 const char* main_file = "hard_vs_soft.h5";
 hid_t file = H5Fcreate(main_file, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);

 hid_t g1 = H5Gcreate(file, "/G1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
 hid_t g2 = H5Gcreate(  g1, "G2",  H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
 hid_t g3 = H5Gcreate(  g1, "G3",  H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
 hid_t g4 = H5Gcreate(file, "/G4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
 hid_t status = H5Lcreate_soft("/G1/G3", g4, "G5_soft", H5P_DEFAULT, 
H5P_DEFAULT);
 {
   // test one hard and one soft link to make sure...
   H5L_info_t info;
   status = H5Lget_info(g1, "G2", &info, H5P_DEFAULT);
   cout << "/G1/G2 is "; printLinkInfo(info.type); cout << endl;
   status = H5Lget_info(g4, "G5_soft", &info, H5P_DEFAULT);
   cout << "/G4/G5_soft is "; printLinkInfo(info.type); cout << endl;
 }
 status = H5Gclose(g4);
 status = H5Gclose(g3);
 status = H5Gclose(g2);
 status = H5Gclose(g1);

 status = H5Fclose(file);

 return 0;
}



Richard.

Jens Thoms Toerring wrote:
Hi Quincy,

On Tue, Oct 12, 2010 at 02:28:41PM -0500, Quincey Koziol wrote:
        Hmm, sorry, I missed that you wanted to check for a soft link.  You
need to use H5Lget_info() for that.

Sorry for bothering you again: is it the expected behaviour of
H5Lget_info() that it reports the type as H5L_TYPE_HARD in the
H5L_info_t structure if what is passed as the 'link_name' argu-
ment is actually just a group? I was expecting to get back a
negative return value but that only seems to happen if a group
or (soft) link with the specified name does not exist. May I
conclude that a group is basically a hard link?

                     Thanks and best regards, Jens

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

Reply via email to