summaryrefslogtreecommitdiffstats
path: root/tools/src
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2021-05-05 22:07:40 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2021-05-05 22:07:40 (GMT)
commit8d4873173fe95ffd8a274c9d9a6c1e8b5e017957 (patch)
tree10a135eaa95a0dfd54925af438504179c439de17 /tools/src
parent54c202e4ec4bc9c7e45543cea5b51868a091b3e9 (diff)
downloadhdf5-8d4873173fe95ffd8a274c9d9a6c1e8b5e017957.zip
hdf5-8d4873173fe95ffd8a274c9d9a6c1e8b5e017957.tar.gz
hdf5-8d4873173fe95ffd8a274c9d9a6c1e8b5e017957.tar.bz2
Brings native H5Fdelete implementation from develop
Diffstat (limited to 'tools/src')
-rw-r--r--tools/src/misc/CMakeLists.txt22
-rw-r--r--tools/src/misc/Makefile.am3
-rw-r--r--tools/src/misc/h5delete.c66
-rw-r--r--tools/src/misc/h5repart.c10
4 files changed, 94 insertions, 7 deletions
diff --git a/tools/src/misc/CMakeLists.txt b/tools/src/misc/CMakeLists.txt
index ea30c98..8811f97 100644
--- a/tools/src/misc/CMakeLists.txt
+++ b/tools/src/misc/CMakeLists.txt
@@ -38,11 +38,20 @@ if (NOT ONLY_SHARED_LIBS)
set_target_properties (h5clear PROPERTIES FOLDER tools)
set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5clear")
+ add_executable (h5delete ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5delete.c)
+ target_include_directories (h5delete PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5delete PRIVATE "${HDF5_CMAKE_C_FLAGS}")
+ TARGET_C_PROPERTIES (h5delete STATIC)
+ target_link_libraries (h5delete PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
+ set_target_properties (h5delete PROPERTIES FOLDER tools)
+ set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5delete")
+
set (H5_DEP_EXECUTABLES
h5debug
h5repart
h5mkgrp
- h5clear
+ h5clear
+ h5delete
)
endif ()
if (BUILD_SHARED_LIBS)
@@ -78,11 +87,20 @@ if (BUILD_SHARED_LIBS)
set_target_properties (h5clear-shared PROPERTIES FOLDER tools)
set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5clear-shared")
+ add_executable (h5delete-shared ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5delete.c)
+ target_include_directories (h5delete-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5delete-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
+ TARGET_C_PROPERTIES (h5delete-shared SHARED)
+ target_link_libraries (h5delete-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
+ set_target_properties (h5delete-shared PROPERTIES FOLDER tools)
+ set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5delete-shared")
+
set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES}
h5debug-shared
h5repart-shared
h5mkgrp-shared
h5clear-shared
+ h5delete-shared
)
endif ()
@@ -95,11 +113,13 @@ if (HDF5_ENABLE_FORMATTERS)
clang_format (HDF5_H5REPART_SRC_FORMAT h5repart)
clang_format (HDF5_H5MKGRP_SRC_FORMAT h5mkgrp)
clang_format (HDF5_H5CLEAR_SRC_FORMAT h5clear)
+ clang_format (HDF5_H5DELETE_SRC_FORMAT h5delete)
else ()
clang_format (HDF5_H5DEBUG_SRC_FORMAT h5debug-shared)
clang_format (HDF5_H5REPART_SRC_FORMAT h5repart-shared)
clang_format (HDF5_H5MKGRP_SRC_FORMAT h5mkgrp-shared)
clang_format (HDF5_H5CLEAR_SRC_FORMAT h5clear-shared)
+ clang_format (HDF5_H5DELETE_SRC_FORMAT h5delete-shared)
endif ()
endif ()
diff --git a/tools/src/misc/Makefile.am b/tools/src/misc/Makefile.am
index e8ee947..cad13c1 100644
--- a/tools/src/misc/Makefile.am
+++ b/tools/src/misc/Makefile.am
@@ -22,13 +22,14 @@ include $(top_srcdir)/config/commence.am
AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/tools/lib
# These are our main targets, the tools
-bin_PROGRAMS=h5debug h5repart h5mkgrp h5clear
+bin_PROGRAMS=h5debug h5repart h5mkgrp h5clear h5delete
# Add h5debug, h5repart, and h5mkgrp specific linker flags here
h5debug_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS)
h5repart_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS)
h5mkgrp_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS)
h5clear_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS)
+h5delete_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS)
# All programs rely on hdf5 library and h5tools library
LDADD=$(LIBH5TOOLS) $(LIBHDF5)
diff --git a/tools/src/misc/h5delete.c b/tools/src/misc/h5delete.c
new file mode 100644
index 0000000..3c4f8d5
--- /dev/null
+++ b/tools/src/misc/h5delete.c
@@ -0,0 +1,66 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/* h5delete tool
+ *
+ * Deletes storage via H5Fdelete() using the VOL connector specified in the
+ * environment variable.
+ */
+
+#include "H5private.h"
+#include "H5Eprivate.h"
+#include "H5Pprivate.h"
+
+static void usage(void);
+
+static void
+usage(void)
+{
+ HDfprintf(stderr, "Usage: h5delete [-f] <filename>\n");
+}
+
+int
+main(int argc, const char *argv[])
+{
+ hbool_t quiet = FALSE;
+ const char *name = NULL;
+ int ret = 0;
+
+ switch (argc) {
+ case 3:
+ if (HDstrcmp(argv[1], "-f") != 0) {
+ usage();
+ return EXIT_FAILURE;
+ }
+ quiet = TRUE;
+ name = argv[2];
+ break;
+ case 2:
+ name = argv[1];
+ break;
+ default:
+ usage();
+ return EXIT_FAILURE;
+ }
+
+ H5E_BEGIN_TRY
+ {
+ /* Only uses the environment variable at this time */
+ ret = (int)H5Fdelete(name, H5P_DEFAULT);
+ }
+ H5E_END_TRY;
+
+ if (ret < 0 && !quiet)
+ HDfprintf(stderr, "Unable to delete storage at: %s\n", name);
+
+ return ret < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
+}
diff --git a/tools/src/misc/h5repart.c b/tools/src/misc/h5repart.c
index e3f00af..f4cef6a 100644
--- a/tools/src/misc/h5repart.c
+++ b/tools/src/misc/h5repart.c
@@ -12,7 +12,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Robb Matzke <matzke@llnl.gov>
+ * Programmer: Robb Matzke
* Wednesday, May 13, 1998
*
* Purpose: Repartitions a file family. This program can be used to
@@ -64,10 +64,10 @@ usage(const char *progname)
"(windows or sec2)\n");
HDfprintf(stderr, " SRC The name of the source file\n");
HDfprintf(stderr, " DST The name of the destination files\n");
- HDfprintf(stderr, "Sizes may be suffixed with `g' for GB, `m' for MB or "
- "`k' for kB.\n");
+ HDfprintf(stderr, "Sizes may be suffixed with 'g' for GB, 'm' for MB or "
+ "'k' for kB.\n");
HDfprintf(stderr, "File family names include an integer printf "
- "format such as `%%d'\n");
+ "format such as '%%d'\n");
HDexit(EXIT_FAILURE);
}
@@ -97,7 +97,7 @@ static off_t
get_size(const char *progname, int *argno, int argc, char *argv[])
{
off_t retval = -1;
- char *suffix;
+ char *suffix = NULL;
if (isdigit((int)(argv[*argno][2]))) {
retval = HDstrtol(argv[*argno] + 2, &suffix, 10);