From ee21dce85ce38fe7f718322b59288aabd3906e76 Mon Sep 17 00:00:00 2001 From: Xuan Bai Date: Wed, 18 Aug 2004 17:00:55 -0500 Subject: [svn-r9110] Purpose: Update. Description: Make some minor change so that h5jam.c is compatible with Windows. Solution: 1. unistd.h is not available in windows system. Add a macro for this header file as: #ifdef H5_HAVE_UNISTD_H #include #endif 2. Change open, read, write, lseek functions to HDopen, HDread, HDwrite, and HDlseek, as these HD functions are more comtatible with Windows system. 3. add #include H5private.h 4. remove #include Platforms tested: Windows 2000 Windows XP eirene (Note: I talked with Bob and Kent about these changes before check-in) Misc. update: --- tools/h5jam/h5jam.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/tools/h5jam/h5jam.c b/tools/h5jam/h5jam.c index 07194cb..f5cdfe0 100644 --- a/tools/h5jam/h5jam.c +++ b/tools/h5jam/h5jam.c @@ -13,12 +13,15 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include -#include #include #include + +#ifdef H5_HAVE_UNISTD_H #include +#endif #include "hdf5.h" +#include "H5private.h" #include "h5tools_utils.h" #define TRUE 1 @@ -233,7 +236,7 @@ main (int argc, const char *argv[]) H5Pclose (plist); H5Fclose (ifile); - ufid = open (ub_file, O_RDONLY); + ufid = HDopen (ub_file, O_RDONLY, 0); if (ufid < 0) { @@ -252,7 +255,7 @@ main (int argc, const char *argv[]) fsize = sbuf.st_size; - h5fid = open (input_file, O_RDONLY); + h5fid = HDopen (input_file, O_RDONLY, 0); if (h5fid < 0) { @@ -273,7 +276,7 @@ main (int argc, const char *argv[]) if (output_file == NULL) { - ofid = open (input_file, O_WRONLY); + ofid = HDopen (input_file, O_WRONLY, 0); if (ofid < 0) { @@ -284,7 +287,7 @@ main (int argc, const char *argv[]) } else { - ofid = open (output_file, O_WRONLY | O_CREAT | O_TRUNC, 0644); + ofid = HDopen (output_file, O_WRONLY | O_CREAT | O_TRUNC, 0644); if (ofid < 0) { @@ -435,23 +438,24 @@ copy_some_to_file (int infid, int outfid, hsize_t startin, hsize_t startout, while (howmuch > 0) { - lseek (outfid, (off_t) to, SEEK_SET); - lseek (infid, (off_t) from, SEEK_SET); + HDlseek (outfid, (off_t) to, SEEK_SET); + HDlseek (infid, (off_t) from, SEEK_SET); if (howmuch > 512) { - nchars = read (infid, buf, (unsigned) 512); + nchars = HDread (infid, buf, (unsigned) 512); } else { - nchars = read (infid, buf, howmuch); + nchars = HDread (infid, buf, howmuch); } + if (nchars <= 0) { printf ("huh? \n"); exit (1); } - /*ncw = */ write (outfid, buf, (unsigned) nchars); + /*ncw = */ HDwrite (outfid, buf, (unsigned) nchars); /* assert (ncw == nchars) */ @@ -526,14 +530,14 @@ write_pad (int ofile, hsize_t where) buf[0] = '\0'; - lseek (ofile, (off_t) where, SEEK_SET); + HDlseek (ofile, (off_t) where, SEEK_SET); psize = compute_user_block_size (where); psize -= where; for (i = 0; i < psize; i++) { - write (ofile, buf, 1); + HDwrite (ofile, buf, 1); } return (where + psize); /* the new size of the file. */ } -- cgit v0.12