summaryrefslogtreecommitdiffstats
path: root/examples/h5dsm_link_exists.c
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2017-02-02 23:27:23 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2017-02-02 23:27:23 (GMT)
commitee91c7320a451fcf0743a7f275b8f0993107a613 (patch)
treec7c7211cc4d307be4fa07075dcb313006d963b9c /examples/h5dsm_link_exists.c
parent2f23c20203eec698964ccdc5f0f2c0cb3a3812e8 (diff)
downloadhdf5-ee91c7320a451fcf0743a7f275b8f0993107a613.zip
hdf5-ee91c7320a451fcf0743a7f275b8f0993107a613.tar.gz
hdf5-ee91c7320a451fcf0743a7f275b8f0993107a613.tar.bz2
Implement H5Lexists. Add h5dsm_link_exists example. Other minor fixes
and cleanup.
Diffstat (limited to 'examples/h5dsm_link_exists.c')
-rw-r--r--examples/h5dsm_link_exists.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/examples/h5dsm_link_exists.c b/examples/h5dsm_link_exists.c
new file mode 100644
index 0000000..4b04acb
--- /dev/null
+++ b/examples/h5dsm_link_exists.c
@@ -0,0 +1,69 @@
+#include "h5dsm_example.h"
+
+int main(int argc, char *argv[]) {
+ uuid_t pool_uuid;
+ char *pool_grp = NULL;
+ hid_t file = -1, fapl = -1;
+ hsize_t dims[1] = {1};
+ H5VL_daosm_snap_id_t snap_id;
+ htri_t link_exists;
+
+ (void)MPI_Init(&argc, &argv);
+ (void)daos_init();
+
+ if(argc < 4 || argc > 5)
+ PRINTF_ERROR("argc must be 4 or 5\n");
+
+ /* Parse UUID */
+ if(0 != uuid_parse(argv[1], pool_uuid))
+ ERROR;
+
+ /* Set up FAPL */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ ERROR;
+ if(H5Pset_fapl_daosm(fapl, MPI_COMM_WORLD, MPI_INFO_NULL, pool_uuid, pool_grp) < 0)
+ ERROR;
+
+ /* Open snapshot if specified */
+ if(argc == 5) {
+ snap_id = (H5VL_daosm_snap_id_t)atoi(argv[4]);
+ printf("Opening snapshot %llu\n", (long long unsigned)snap_id);
+ if(H5Pset_daosm_snap_open(fapl, snap_id) < 0)
+ ERROR;
+ } /* end if */
+
+ /* Open file */
+ if((file = H5Fopen(argv[2], H5F_ACC_RDONLY, fapl)) < 0)
+ ERROR;
+
+ printf("Checking if link exists... ");
+
+ /* Check link */
+ if((link_exists = H5Lexists(file, argv[3], H5P_DEFAULT)) < 0)
+ ERROR;
+
+ printf("%s\n", link_exists ? "TRUE" : "FALSE");
+
+ /* Close */
+ if(H5Fclose(file) < 0)
+ ERROR;
+ if(H5Pclose(fapl) < 0)
+ ERROR;
+
+ printf("Success\n");
+
+ (void)daos_fini();
+ (void)MPI_Finalize();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ H5Pclose(fapl);
+ } H5E_END_TRY;
+
+ (void)daos_fini();
+ (void)MPI_Finalize();
+ return 1;
+}
+