summaryrefslogtreecommitdiffstats
path: root/tools/h5repack/h5repack_copy.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2016-09-28 18:06:02 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2016-09-28 18:06:02 (GMT)
commit208cfdc941bd911253051dc496c087dae6012241 (patch)
treea91d11ade122596d7e7eb44f8468efd2a50d7d38 /tools/h5repack/h5repack_copy.c
parent50d3fc7a61f4b1dbe2ead376b778f5743060cc6e (diff)
downloadhdf5-208cfdc941bd911253051dc496c087dae6012241.zip
hdf5-208cfdc941bd911253051dc496c087dae6012241.tar.gz
hdf5-208cfdc941bd911253051dc496c087dae6012241.tar.bz2
Merge/align from trunk(develop)
Diffstat (limited to 'tools/h5repack/h5repack_copy.c')
-rw-r--r--tools/h5repack/h5repack_copy.c106
1 files changed, 43 insertions, 63 deletions
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c
index 547f61a..9573ee8 100644
--- a/tools/h5repack/h5repack_copy.c
+++ b/tools/h5repack/h5repack_copy.c
@@ -33,7 +33,7 @@
*/
/* size of buffer/# of bytes to xfer at a time when copying userblock */
-#define USERBLOCK_XFER_SIZE 512
+#define USERBLOCK_XFER_SIZE 512
/* check H5Dread()/H5Dwrite() error, e.g. memory allocation error inside the library. */
#define CHECK_H5DRW_ERROR(_fun, _fail, _did, _mtid, _msid, _fsid, _pid, _buf) { \
@@ -54,12 +54,12 @@
*-------------------------------------------------------------------------
*/
static int Get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[],
- size_t size_datum, hsize_t dims_hslab[], hsize_t * hslab_nbytes_p);
+ size_t size_datum, hsize_t dims_hslab[], hsize_t * hslab_nbytes_p);
static void print_dataset_info(hid_t dcpl_id, char *objname, double per, int pr);
static int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
- pack_opt_t *options);
+ pack_opt_t *options);
static int copy_user_block(const char *infile, const char *outfile,
- hsize_t size);
+ hsize_t size);
#if defined (H5REPACK_DEBUG_USER_BLOCK)
static void print_user_block(const char *filename, hid_t fid);
#endif
@@ -67,10 +67,10 @@ static herr_t walk_error_callback(unsigned n, const H5E_error2_t *err_desc, void
/* get the major number from the error stack. */
static herr_t walk_error_callback(H5_ATTR_UNUSED unsigned n, const H5E_error2_t *err_desc, void *udata) {
- if (err_desc)
- *((hid_t *) udata) = err_desc->maj_num;
+ if (err_desc)
+ *((hid_t *) udata) = err_desc->maj_num;
- return 0;
+ return 0;
}
/*-------------------------------------------------------------------------
@@ -130,20 +130,6 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
- if (!options->fs_strategy) {
- if (H5Pget_file_space(fcpl_in, &options->fs_strategy, NULL) < 0) {
- error_msg("failed to retrieve file space strategy\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
- }
- }
-
- if (!options->fs_threshold) {
- if (H5Pget_file_space(fcpl_in, NULL, &options->fs_threshold) < 0) {
- error_msg("failed to retrieve file space threshold\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
- }
- }
-
if (H5Pclose(fcpl_in) < 0) {
error_msg("failed to close property list\n");
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
@@ -314,12 +300,6 @@ print_user_block(fnamein, fidin);
}
}
- /* set file space strategy and free space threshold */
- if (H5Pset_file_space(fcpl, options->fs_strategy, options->fs_threshold) < 0) {
- error_msg("failed to set file space strategy & threshold \n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
- }
-
/*-------------------------------------------------------------------------
* create the output file
*-------------------------------------------------------------------------
@@ -679,7 +659,7 @@ done:
*/
int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
- pack_opt_t *options) /* repack options */
+ pack_opt_t *options) /* repack options */
{
int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
hid_t grp_in = -1; /* group ID */
@@ -1517,65 +1497,65 @@ void print_user_block(const char *filename, hid_t fid)
{
int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
int fh; /* file handle */
- hsize_t ub_size; /* user block size */
- hsize_t size; /* size read */
- hid_t fcpl; /* file creation property list ID for HDF5 file */
- int i;
-
- /* get user block size */
- if(( fcpl = H5Fget_create_plist(fid)) < 0) {
- error_msg("failed to retrieve file creation property list\n");
+ hsize_t ub_size; /* user block size */
+ hsize_t size; /* size read */
+ hid_t fcpl; /* file creation property list ID for HDF5 file */
+ int i;
+
+ /* get user block size */
+ if(( fcpl = H5Fget_create_plist(fid)) < 0) {
+ error_msg("failed to retrieve file creation property list\n");
HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Fget_create_plist failed");
}
- if(H5Pget_userblock(fcpl, &ub_size) < 0) {
- error_msg("failed to retrieve userblock size\n");
+ if(H5Pget_userblock(fcpl, &ub_size) < 0) {
+ error_msg("failed to retrieve userblock size\n");
HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pget_userblock failed");
}
- if(H5Pclose(fcpl) < 0) {
- error_msg("failed to close property list\n");
+ if(H5Pclose(fcpl) < 0) {
+ error_msg("failed to close property list\n");
HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
}
- /* open file */
- if((fh = HDopen(filename, O_RDONLY, 0)) < 0) {
+ /* open file */
+ if((fh = HDopen(filename, O_RDONLY, 0)) < 0) {
HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDopen failed");
}
- size = ub_size;
+ size = ub_size;
- /* read file */
- while(size > 0) {
- ssize_t nread; /* # of bytes read */
- char rbuf[USERBLOCK_XFER_SIZE]; /* buffer for reading */
+ /* read file */
+ while(size > 0) {
+ ssize_t nread; /* # of bytes read */
+ char rbuf[USERBLOCK_XFER_SIZE]; /* buffer for reading */
- /* read buffer */
- if(size > USERBLOCK_XFER_SIZE)
- nread = HDread(fh, rbuf, (size_t)USERBLOCK_XFER_SIZE);
- else
- nread = HDread(fh, rbuf, (size_t)size);
+ /* read buffer */
+ if(size > USERBLOCK_XFER_SIZE)
+ nread = HDread(fh, rbuf, (size_t)USERBLOCK_XFER_SIZE);
+ else
+ nread = HDread(fh, rbuf, (size_t)size);
- for(i = 0; i < nread; i++) {
+ for(i = 0; i < nread; i++) {
- printf("%c ", rbuf[i]);
+ printf("%c ", rbuf[i]);
- }
- printf("\n");
+ }
+ printf("\n");
- if(nread < 0) {
+ if(nread < 0) {
HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "nread < 0");
}
- /* update size of userblock left to transfer */
- size -= nread;
- }
+ /* update size of userblock left to transfer */
+ size -= nread;
+ }
done:
- if(fh > 0)
- HDclose(fh);
+ if(fh > 0)
+ HDclose(fh);
- return;
+ return;
}
#endif