diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2003-12-18 20:25:11 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2003-12-18 20:25:11 (GMT) |
commit | 5658d883277c915fa56c111bbb21a487a0659e1f (patch) | |
tree | cce6746b89fcc35e491b58b418f8d83c7e4c2900 /tools/h5repack | |
parent | 5b518c102d14f036116e98244fc6856a6c49dc3c (diff) | |
download | hdf5-5658d883277c915fa56c111bbb21a487a0659e1f.zip hdf5-5658d883277c915fa56c111bbb21a487a0659e1f.tar.gz hdf5-5658d883277c915fa56c111bbb21a487a0659e1f.tar.bz2 |
[svn-r7971] Purpose:
h5repack bug
Description:
changed the copy hardlinks algorithm
added more tests
Solution:
Platforms tested:
linux
solaris
IRIX
Misc. update:
Diffstat (limited to 'tools/h5repack')
-rw-r--r-- | tools/h5repack/h5repack_list.c | 51 | ||||
-rw-r--r-- | tools/h5repack/testh5repack_filters.c | 27 |
2 files changed, 42 insertions, 36 deletions
diff --git a/tools/h5repack/h5repack_list.c b/tools/h5repack/h5repack_list.c index a285e3f..3d43ec1 100644 --- a/tools/h5repack/h5repack_list.c +++ b/tools/h5repack/h5repack_list.c @@ -37,9 +37,9 @@ int check_objects(const char* fname, pack_opt_t *options) { - hid_t fid; - int nobjects, i; - trav_info_t *info=NULL; + hid_t fid; + int i; + trav_table_t *travt=NULL; /*------------------------------------------------------------------------- * open the file @@ -59,28 +59,16 @@ int check_objects(const char* fname, /*------------------------------------------------------------------------- - * get the number of objects in the file - *------------------------------------------------------------------------- - */ - - if ((nobjects = h5trav_getinfo(fid, NULL ))<0) { - printf("h5repack: <%s>: Could not obtain object list\n", fname ); - return -1; - } - -/*------------------------------------------------------------------------- * get the list of objects in the file *------------------------------------------------------------------------- */ - if ((info = (trav_info_t*) malloc( nobjects * sizeof(trav_info_t)))==NULL){ - printf("h5repack: <%s>: Could not allocate object list\n", fname ); - return -1; - } - if (h5trav_getinfo(fid, info )<0) { - printf("h5repack: <%s>: Could not obtain object list\n", fname ); - return -1; - } + /* init table */ + trav_table_init(&travt); + + /* get the list of objects in the file */ + if (h5trav_gettable(fid,travt)<0) + goto out; /*------------------------------------------------------------------------- * compare with user supplied list @@ -92,29 +80,32 @@ int check_objects(const char* fname, for ( i = 0; i < options->op_tbl->nelems; i++) { - char* obj_name=options->op_tbl->objs[i].path; + char* name=options->op_tbl->objs[i].path; if (options->verbose) - printf(PFORMAT1,"","",obj_name); + printf(PFORMAT1,"","",name); /* the input object names are present in the file and are valid */ - if (h5trav_getindex(obj_name,nobjects,info)<0) + if (h5trav_getindext(name,travt)<0) { printf("\nError: Could not find <%s> in file <%s>. Exiting...\n", - obj_name,fname); - H5Fclose(fid); - h5trav_freeinfo(info,nobjects); - exit(1); + name,fname); + goto out; } if (options->verbose) printf("...Found\n"); } /*------------------------------------------------------------------------- - * free + * close *------------------------------------------------------------------------- */ H5Fclose(fid); - h5trav_freeinfo(info,nobjects); + trav_table_free(travt); return 0; + +out: + H5Fclose(fid); + trav_table_free(travt); + return -1; } diff --git a/tools/h5repack/testh5repack_filters.c b/tools/h5repack/testh5repack_filters.c index dd72813..9067ff0 100644 --- a/tools/h5repack/testh5repack_filters.c +++ b/tools/h5repack/testh5repack_filters.c @@ -336,7 +336,6 @@ int make_special_objects(hid_t loc_id) hsize_t dims[1]={2}; int buf[2]= {1,2}; - /*------------------------------------------------------------------------- * create a dataset and some hard links to it *------------------------------------------------------------------------- @@ -351,25 +350,41 @@ int make_special_objects(hid_t loc_id) if (H5Glink(loc_id, H5G_LINK_HARD, "dset", "link3 to dset")<0) return -1; + /*------------------------------------------------------------------------- * create a group and some hard links to it *------------------------------------------------------------------------- */ - + if ((group1_id = H5Gcreate(loc_id,"g1",0))<0) return -1; if ((group2_id = H5Gcreate(group1_id,"g2",0))<0) return -1; if ((group3_id = H5Gcreate(group2_id,"g3",0))<0) return -1; - if (H5Glink(loc_id, H5G_LINK_HARD, "g1", "link1 to g1")<0) - return -1; - if (H5Glink(loc_id, H5G_LINK_HARD, "g1", "link2 to g1")<0) - return -1; + /* + H5Glink2(curr_loc_id, current_name, link_type, new_loc_id, new_name ) + hid_t curr_loc_id + IN: The file or group identifier for the original object. + const char * current_name + IN: Name of the existing object if link is a hard link. + H5G_link_t link_type + IN: Link type. Possible values are H5G_LINK_HARD and H5G_LINK_SOFT. + hid_t new_loc_id + IN: The file or group identifier for the new link. + const char * new_name + IN: New name for the object. + */ + if (H5Glink2(loc_id, "g1", H5G_LINK_HARD, group2_id, "link1 to g1")<0) + return -1; + if (H5Glink2(group1_id, "g2", H5G_LINK_HARD, group3_id, "link1 to g2")<0) + return -1; + H5Gclose(group1_id); H5Gclose(group2_id); + H5Gclose(group3_id); return 0; |