summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>2002-12-04 15:44:07 (GMT)
committerRobb Matzke <matzke@llnl.gov>2002-12-04 15:44:07 (GMT)
commit76f7bb10ac47d44e07fb31d72a689e51b5112ba8 (patch)
treedd20ac10a3d6819737a8ff36f1026ec2736fa797
parentb081991663dfa001eb39b2fbda153f2b2277b9bf (diff)
downloadhdf5-76f7bb10ac47d44e07fb31d72a689e51b5112ba8.zip
hdf5-76f7bb10ac47d44e07fb31d72a689e51b5112ba8.tar.gz
hdf5-76f7bb10ac47d44e07fb31d72a689e51b5112ba8.tar.bz2
[svn-r6179] ./hdf5-devel/tools/h5ls/h5ls.c
Purpose: New Feature; Optimization; Clean-up (Merged from 1.4 branch) Description: There is no symbolic constant to pass to functions that take an optional object ID for when the caller wants to indicate no object ID. In the past the caller always passed a negative integer. GPFS performs poorly. The h5ls tool decides whether to list the file name in the output based on a compile-time choice, which isn't always optimal at run time. Solution: Added a symbolic constant H5I_INVALID_HID. Added code to tell the mmfsd of GPFS to forego byte range token prefetching. h5ls decides whether to print the file name at runtime based on the number of objects being listed. Platforms tested: SuSE Linux (arborea), gcc and mpich-1.2.4 SunOS (baldric), gcc 2002-12-03 23:00:35 Robb Matzke <matzke@arborea.spizella.com> * main: Replaced the H5LS_PREPEND_FILENAME compile-time symbol which was always defined, with a runtime decision. If h5ls is invoked with more than one argument then the file name is displayed as part of the object name, otherwise the file name is not displayed.
-rw-r--r--tools/h5ls/h5ls.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c
index b414319..fd44113 100644
--- a/tools/h5ls/h5ls.c
+++ b/tools/h5ls/h5ls.c
@@ -17,12 +17,6 @@
#include "h5tools.h"
#include "h5tools_utils.h"
-/*
- * If defined then include the file name as part of the object name when
- * printing full object names. Otherwise leave the file name off.
- */
-#define H5LS_PREPEND_FILENAME
-
/* Command-line switches */
static int verbose_g = 0; /*lots of extra output */
static int width_g = 80; /*output width in characters */
@@ -36,6 +30,7 @@ static hbool_t grp_literal_g = FALSE; /*list group, not contents */
static hbool_t hexdump_g = FALSE; /*show data as raw hexadecimal */
static hbool_t show_errors_g = FALSE; /*print HDF5 error messages */
static hbool_t simple_output_g = FALSE; /*make output more machine-readable */
+static hbool_t show_file_name_g = FALSE;/*show file name for full names */
/* Info to pass to the iteration functions */
typedef struct iter_t {
@@ -1816,9 +1811,6 @@ fix_name(const char *path, const char *base)
if (path) {
/* Path, followed by slash */
-#ifdef H5LS_PREPEND_FILENAME
- if ('/'!=*path) s[len++] = '/';
-#endif
for (/*void*/; *path; path++) {
if ('/'!=*path || '/'!=prev) prev = s[len++] = *path;
}
@@ -2129,6 +2121,7 @@ main (int argc, char *argv[])
* then there must have been something wrong with the file (perhaps it
* doesn't exist).
*/
+ show_file_name_g = (argc-argno > 1); /*show file names if more than one*/
while (argno<argc) {
fname = argv[argno++];
oname = NULL;
@@ -2167,11 +2160,7 @@ main (int argc, char *argv[])
* group.
*/
sym_insert(&sb, oname);
-#ifdef H5LS_PREPEND_FILENAME
- iter.container = container = fix_name(fname, oname);
-#else
- iter.container = container = fix_name("", oname);
-#endif
+ iter.container = container = fix_name(show_file_name_g?fname:"", oname);
H5Giterate(file, oname, NULL, list, &iter);
free(container);
@@ -2183,11 +2172,7 @@ main (int argc, char *argv[])
* Specified name is a non-group object -- list that object. The
* container for the object is everything up to the base name.
*/
-#ifdef H5LS_PREPEND_FILENAME
- iter.container = fname;
-#else
- iter.container = "/";
-#endif
+ iter.container = show_file_name_g ? fname : "/";
list(root, oname, &iter);
if (H5Gclose(root)<0) exit(1);
}