diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2016-06-14 23:07:03 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2016-06-14 23:07:03 (GMT) |
commit | d3396a79532601bf22e385f94b12e55dfb2c3bd0 (patch) | |
tree | dedf3566ea2ebf40c2d7475e8a50a3f2f0d57774 /tools/h5jam | |
parent | 7a9e13afdb134bafc070cf8bd2087a84fd0d2334 (diff) | |
download | hdf5-d3396a79532601bf22e385f94b12e55dfb2c3bd0.zip hdf5-d3396a79532601bf22e385f94b12e55dfb2c3bd0.tar.gz hdf5-d3396a79532601bf22e385f94b12e55dfb2c3bd0.tar.bz2 |
[svn-r30075] Description:
Bring object/dataset/group/named datatype features from revise_chunks
branch to trunk. Also CMake support for h5format_convert and a bunch of
misc. cleanups.
Tested on:
MacOSX/64 10.11.5 (amazon) w/serial, parallel & production
(h5committest forthcoming)
Diffstat (limited to 'tools/h5jam')
-rw-r--r-- | tools/h5jam/h5jam.c | 35 | ||||
-rw-r--r-- | tools/h5jam/h5jamgentest.c | 27 |
2 files changed, 40 insertions, 22 deletions
diff --git a/tools/h5jam/h5jam.c b/tools/h5jam/h5jam.c index 4509734..ae45714 100644 --- a/tools/h5jam/h5jam.c +++ b/tools/h5jam/h5jam.c @@ -21,7 +21,7 @@ /* Name of tool */ #define PROGRAMNAME "h5jam" -hsize_t write_pad (int, hsize_t); +herr_t write_pad(int ofile, hsize_t old_where, hsize_t *new_where); hsize_t compute_user_block_size (hsize_t); hsize_t copy_some_to_file (int, int, hsize_t, hsize_t, ssize_t); void parse_command_line (int, const char *[]); @@ -380,7 +380,13 @@ main (int argc, const char *argv[]) where = copy_some_to_file (ufid, ofid, (hsize_t) 0, startub, (ssize_t) - 1); /* pad the ub */ - where = write_pad (ofid, where); + if(write_pad(ofid, where, &where) < 0) { + error_msg("Can't pad file \"%s\"\n", output_file); + HDclose (h5fid); + HDclose (ufid); + HDclose (ofid); + leave (EXIT_FAILURE); + } /* end if */ if(ub_file) HDfree (ub_file); @@ -534,25 +540,32 @@ compute_user_block_size(hsize_t ublock_size) /* * Write zeroes to fill the file from 'where' to 512, 1024, etc. bytes. * - * Returns the size of the padded file. + * Sets new_where to the size of the padded file and + * returns SUCCEED/FAIL. */ -hsize_t -write_pad(int ofile, hsize_t where) +herr_t +write_pad(int ofile, hsize_t old_where, hsize_t *new_where) { unsigned int i; char buf[1]; hsize_t psize; + HDassert(new_where); + buf[0] = '\0'; - HDlseek(ofile, (off_t) where, SEEK_SET); + HDlseek(ofile, (off_t)old_where, SEEK_SET); - psize = compute_user_block_size (where); - psize -= where; + psize = compute_user_block_size(old_where); + psize -= old_where; for(i = 0; i < psize; i++) - HDwrite (ofile, buf, 1); + if(HDwrite(ofile, buf, 1) < 0) + return FAIL; - return(where + psize); /* the new size of the file. */ -} + /* Set the new size of the file. */ + *new_where = old_where + psize; + + return SUCCEED; +} /* end write_pad() */ diff --git a/tools/h5jam/h5jamgentest.c b/tools/h5jam/h5jamgentest.c index d3166b5..7ae3169 100644 --- a/tools/h5jam/h5jamgentest.c +++ b/tools/h5jam/h5jamgentest.c @@ -275,20 +275,23 @@ gent_ub(const char * filename, size_t ub_size, size_t ub_fill) /* If a user block is being used, write to it here */ if(ub_size > 0) { - HDassert(ub_size <= BUF_SIZE); + ssize_t nbytes; - fd = HDopen(filename, O_RDWR, 0); - HDassert(fd >= 0); + HDassert(ub_size <= BUF_SIZE); - /* fill buf with pattern */ - HDmemset(buf, '\0', ub_size); - bp = buf; - for (u = 0; u < ub_fill; u++) - *bp++ = pattern[u % 10]; + fd = HDopen(filename, O_RDWR, 0); + HDassert(fd >= 0); - HDwrite(fd, buf, ub_size); + /* fill buf with pattern */ + HDmemset(buf, '\0', ub_size); + bp = buf; + for (u = 0; u < ub_fill; u++) + *bp++ = pattern[u % 10]; - HDclose(fd); + nbytes = HDwrite(fd, buf, ub_size); + HDassert(nbytes >= 0); + + HDclose(fd); } } @@ -299,6 +302,7 @@ create_textfile(const char *name, size_t size) int fd; size_t i; char *bp; + ssize_t nbytes; fd = HDcreat(name,0777); HDassert(fd >= 0); @@ -310,7 +314,8 @@ create_textfile(const char *name, size_t size) for(i = 0; i < size; i++) *bp++ = pattern[i % 10]; - HDwrite(fd, buf, size); + nbytes = HDwrite(fd, buf, size); + HDassert(nbytes >= 0); HDfree(buf); |