aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2014-09-18 16:33:05 +0200
committerThomas White <taw@physics.org>2014-09-18 16:33:05 +0200
commitd0443d87cd0fb6a85b1bd26d0746853af19c853e (patch)
treeb9c6ec90cba71ca67a7010bf437324852b71d285
parenta8f6209b59df897d0aa5d398a0ee8d54e1df3a81 (diff)
Use H5Lexists() instead of H5Gget_objinfo()
This fixes some HDF5 console splurge when saving an image
-rw-r--r--libcrystfel/src/hdf5-file.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/libcrystfel/src/hdf5-file.c b/libcrystfel/src/hdf5-file.c
index f5eaef02..5093ed84 100644
--- a/libcrystfel/src/hdf5-file.c
+++ b/libcrystfel/src/hdf5-file.c
@@ -507,7 +507,7 @@ int hdf5_write_image(const char *filename, struct image *image, char *element)
for ( li=0; li<num_locations; li++ ) {
- hid_t ph, gph;
+ hid_t ph;
hid_t dh_dataspace;
hsize_t size[2];
@@ -520,16 +520,19 @@ int hdf5_write_image(const char *filename, struct image *image, char *element)
return 1;
}
+ if ( group != NULL ) {
- gph = H5Pcreate(H5P_LINK_CREATE);
- H5Pset_create_intermediate_group(gph, 1);
+ htri_t exists;
+ hid_t gph = H5Pcreate(H5P_LINK_CREATE);
+ H5Pset_create_intermediate_group(gph, 1);
- if ( group != NULL ) {
- fail = H5Gget_objinfo (fh, group, 0, NULL);
- if ( fail ) {
+ exists = H5Lexists(fh, group, H5P_DEFAULT);
+
+ if ( !exists ) {
gh = H5Gcreate2(fh, group, gph, H5P_DEFAULT,
H5P_DEFAULT);
+ H5Pclose(gph);
if ( gh < 0 ) {
ERROR("Couldn't create group\n");
H5Fclose(fh);
@@ -599,7 +602,6 @@ int hdf5_write_image(const char *filename, struct image *image, char *element)
free(group);
free(object);
H5Pclose(ph);
- H5Pclose(gph);
H5Dclose(dh);
H5Sclose(dh_dataspace);
H5Sclose(sh);
@@ -626,7 +628,6 @@ int hdf5_write_image(const char *filename, struct image *image, char *element)
free(group);
free(object);
H5Pclose(ph);
- H5Pclose(gph);
H5Dclose(dh);
H5Sclose(dh_dataspace);
H5Sclose(sh);
@@ -643,7 +644,6 @@ int hdf5_write_image(const char *filename, struct image *image, char *element)
free(group);
free(object);
H5Pclose(ph);
- H5Pclose(gph);
H5Sclose(sh);
H5Dclose(dh);
if ( gh != -1 ) H5Gclose(gh);