diff options
Diffstat (limited to 'src/H5FDstdio.c')
-rw-r--r-- | src/H5FDstdio.c | 436 |
1 files changed, 215 insertions, 221 deletions
diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index 4eab71f..5c40d15 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -14,12 +14,12 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Robb Matzke <matzke@llnl.gov> - * Wednesday, October 22, 1997 + * Programmer: Robb Matzke <matzke@llnl.gov> + * Wednesday, October 22, 1997 * - * Purpose: This is the Posix stdio.h I/O subclass of H5Flow. - * It also serves as an example of coding a simple file driver, - * therefore, it should not use any non-public definitions. + * Purpose: This is the Posix stdio.h I/O subclass of H5Flow. + * It also serves as an example of coding a simple file driver, + * therefore, it should not use any non-public definitions. * * Notes: Ported to the new H5FD architecture on 10/18/99 - QAK * @@ -43,7 +43,7 @@ #include <unistd.h> #endif -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API #include <windows.h> #include <io.h> @@ -58,7 +58,7 @@ #ifdef MAX #undef MAX #endif /* MAX */ -#define MAX(X,Y) ((X)>(Y)?(X):(Y)) +#define MAX(X,Y) ((X)>(Y)?(X):(Y)) /* The driver identification number, initialized at runtime */ static hid_t H5FD_STDIO_g = 0; @@ -84,23 +84,23 @@ typedef enum { * occurs), and `op' will be set to H5F_OP_UNKNOWN. */ typedef struct H5FD_stdio_t { - H5FD_t pub; /*public stuff, must be first */ - FILE * fp; /*the file handle */ - haddr_t eoa; /*end of allocated region */ - haddr_t eof; /*end of file; current file size*/ - haddr_t pos; /*current file I/O position */ - H5FD_stdio_file_op op; /*last operation */ + H5FD_t pub; /*public stuff, must be first */ + FILE * fp; /*the file handle */ + haddr_t eoa; /*end of allocated region */ + haddr_t eof; /*end of file; current file size*/ + haddr_t pos; /*current file I/O position */ + H5FD_stdio_file_op op; /*last operation */ unsigned write_access; /* Flag to indicate the file was opened with write access */ -#ifndef _WIN32 +#ifndef H5_HAVE_WIN32_API /* * On most systems the combination of device and i-node number uniquely * identify a file. */ - dev_t device; /*file device number */ - ino_t inode; /*file i-node number */ + dev_t device; /*file device number */ + ino_t inode; /*file i-node number */ #else /* - * On _WIN32 the low-order word of a unique identifier associated with the + * On H5_HAVE_WIN32_API the low-order word of a unique identifier associated with the * file and the volume serial number uniquely identify a file. This number * (which, both? -rpm) may change when the system is restarted or when the * file is opened. After a process opens a file, the identifier is @@ -117,18 +117,11 @@ typedef struct H5FD_stdio_t { } H5FD_stdio_t; /* Use similar structure as in H5private.h by defining Windows stuff first. */ -#ifdef _WIN32 - #if _MSC_VER > 1310 /* Newer than VS.NET 2003 */ - # define file_fseek _fseeki64 - # define file_offset_t __int64 - # define file_ftruncate _chsize_s /* Supported in VS 2005 or newer */ - # define file_ftell _ftelli64 - #else - # define file_fseek fseek - # define file_offset_t long - # define file_ftruncate _chsize - # define file_ftell ftell - #endif +#ifdef H5_HAVE_WIN32_API + # define file_fseek _fseeki64 + # define file_offset_t __int64 + # define file_ftruncate _chsize_s /* Supported in VS 2005 or newer */ + # define file_ftell _ftelli64 #endif /* Use file_xxx to indicate these are local macros, avoiding confusing @@ -138,15 +131,15 @@ typedef struct H5FD_stdio_t { */ #ifndef file_fseek #ifdef H5_HAVE_FSEEKO64 - # define file_fseek fseeko64 - # define file_offset_t off64_t - # define file_ftruncate ftruncate64 - # define file_ftell ftello64 + # define file_fseek fseeko64 + # define file_offset_t off64_t + # define file_ftruncate ftruncate64 + # define file_ftell ftello64 #else - # define file_fseek fseeko - # define file_offset_t off_t - # define file_ftruncate ftruncate - # define file_ftell ftello + # define file_fseek fseeko + # define file_offset_t off_t + # define file_ftruncate ftruncate + # define file_ftell ftello #endif #endif @@ -154,25 +147,26 @@ typedef struct H5FD_stdio_t { * These macros check for overflow of various quantities. These macros * assume that file_offset_t is signed and haddr_t and size_t are unsigned. * - * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' - * is too large to be represented by the second argument - * of the file seek function. + * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' + * is too large to be represented by the second argument + * of the file seek function. * - * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too - * large to be represented by the `size_t' type. + * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too + * large to be represented by the `size_t' type. * - * REGION_OVERFLOW: Checks whether an address and size pair describe data - * which can be addressed entirely by the second - * argument of the file seek function. + * REGION_OVERFLOW: Checks whether an address and size pair describe data + * which can be addressed entirely by the second + * argument of the file seek function. */ /* adding for windows NT filesystem support. */ #define MAXADDR (((haddr_t)1<<(8*sizeof(file_offset_t)-1))-1) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || ((A) & ~(haddr_t)MAXADDR)) -#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) -#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ +#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || ((A) & ~(haddr_t)MAXADDR)) +#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) +#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ HADDR_UNDEF==(A)+(Z) || (file_offset_t)((A)+(Z))<(file_offset_t)(A)) /* Prototypes */ +static herr_t H5FD_stdio_term(void); static H5FD_t *H5FD_stdio_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); static herr_t H5FD_stdio_close(H5FD_t *lf); @@ -191,51 +185,52 @@ static herr_t H5FD_stdio_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing); static herr_t H5FD_stdio_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); static const H5FD_class_t H5FD_stdio_g = { - "stdio", /*name */ - MAXADDR, /*maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - NULL, /*sb_size */ - NULL, /*sb_encode */ - NULL, /*sb_decode */ - 0, /*fapl_size */ - NULL, /*fapl_get */ - NULL, /*fapl_copy */ - NULL, /*fapl_free */ - 0, /*dxpl_size */ - NULL, /*dxpl_copy */ - NULL, /*dxpl_free */ - H5FD_stdio_open, /*open */ - H5FD_stdio_close, /*close */ - H5FD_stdio_cmp, /*cmp */ - H5FD_stdio_query, /*query */ - NULL, /*get_type_map */ - H5FD_stdio_alloc, /*alloc */ - NULL, /*free */ - H5FD_stdio_get_eoa, /*get_eoa */ - H5FD_stdio_set_eoa, /*set_eoa */ - H5FD_stdio_get_eof, /*get_eof */ + "stdio", /*name */ + MAXADDR, /*maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD_stdio_term, /*terminate */ + NULL, /*sb_size */ + NULL, /*sb_encode */ + NULL, /*sb_decode */ + 0, /*fapl_size */ + NULL, /*fapl_get */ + NULL, /*fapl_copy */ + NULL, /*fapl_free */ + 0, /*dxpl_size */ + NULL, /*dxpl_copy */ + NULL, /*dxpl_free */ + H5FD_stdio_open, /*open */ + H5FD_stdio_close, /*close */ + H5FD_stdio_cmp, /*cmp */ + H5FD_stdio_query, /*query */ + NULL, /*get_type_map */ + H5FD_stdio_alloc, /*alloc */ + NULL, /*free */ + H5FD_stdio_get_eoa, /*get_eoa */ + H5FD_stdio_set_eoa, /*set_eoa */ + H5FD_stdio_get_eof, /*get_eof */ H5FD_stdio_get_handle, /*get_handle */ - H5FD_stdio_read, /*read */ - H5FD_stdio_write, /*write */ - H5FD_stdio_flush, /*flush */ - H5FD_stdio_truncate, /*truncate */ + H5FD_stdio_read, /*read */ + H5FD_stdio_write, /*write */ + H5FD_stdio_flush, /*flush */ + H5FD_stdio_truncate, /*truncate */ NULL, /*lock */ NULL, /*unlock */ - H5FD_FLMAP_SINGLE /*fl_map */ + H5FD_FLMAP_SINGLE /*fl_map */ }; /*------------------------------------------------------------------------- - * Function: H5FD_stdio_init + * Function: H5FD_stdio_init * - * Purpose: Initialize this driver by registering the driver with the - * library. + * Purpose: Initialize this driver by registering the driver with the + * library. * - * Return: Success: The driver ID for the stdio driver. + * Return: Success: The driver ID for the stdio driver. * - * Failure: Negative. + * Failure: Negative. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: @@ -256,39 +251,38 @@ H5FD_stdio_init(void) /*--------------------------------------------------------------------------- - * Function: H5FD_stdio_term + * Function: H5FD_stdio_term * - * Purpose: Shut down the VFD + * Purpose: Shut down the VFD * - * Return: <none> + * Returns: Non-negative on success or negative on failure * * Programmer: Quincey Koziol * Friday, Jan 30, 2004 * - * Modification: - * *--------------------------------------------------------------------------- */ -void +static herr_t H5FD_stdio_term(void) { /* Reset VFL ID */ H5FD_STDIO_g=0; + return 0; } /* end H5FD_stdio_term() */ /*------------------------------------------------------------------------- - * Function: H5Pset_fapl_stdio + * Function: H5Pset_fapl_stdio * - * Purpose: Modify the file access property list to use the H5FD_STDIO - * driver defined in this source file. There are no driver - * specific properties. + * Purpose: Modify the file access property list to use the H5FD_STDIO + * driver defined in this source file. There are no driver + * specific properties. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Thursday, February 19, 1998 + * Programmer: Robb Matzke + * Thursday, February 19, 1998 * * Modifications: * Stolen from the sec2 driver - QAK, 10/18/99 @@ -313,27 +307,27 @@ H5Pset_fapl_stdio(hid_t fapl_id) /*------------------------------------------------------------------------- - * Function: H5FD_stdio_open + * Function: H5FD_stdio_open * - * Purpose: Create and/or opens a Standard C file as an HDF5 file. + * Purpose: Create and/or opens a Standard C file as an HDF5 file. * - * Bugs: H5F_ACC_EXCL has a race condition. (? -QAK) + * Bugs: H5F_ACC_EXCL has a race condition. (? -QAK) * * Errors: - * IO CANTOPENFILE File doesn't exist and CREAT wasn't - * specified. - * IO CANTOPENFILE Fopen failed. - * IO FILEEXISTS File exists but CREAT and EXCL were - * specified. + * IO CANTOPENFILE File doesn't exist and CREAT wasn't + * specified. + * IO CANTOPENFILE Fopen failed. + * IO FILEEXISTS File exists but CREAT and EXCL were + * specified. * - * Return: Success: A pointer to a new file data structure. The - * public fields will be initialized by the - * caller, which is always H5FD_open(). + * Return: Success: A pointer to a new file data structure. The + * public fields will be initialized by the + * caller, which is always H5FD_open(). * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke - * Wednesday, October 22, 1997 + * Programmer: Robb Matzke + * Wednesday, October 22, 1997 * * Modifications: * Ported to VFL/H5FD layer - QAK, 10/18/99 @@ -344,17 +338,17 @@ static H5FD_t * H5FD_stdio_open( const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - FILE *f = NULL; + FILE *f = NULL; unsigned write_access=0; /* File opened with write access? */ - H5FD_stdio_t *file=NULL; + H5FD_stdio_t *file=NULL; static const char *func="H5FD_stdio_open"; /* Function Name for error reporting */ -#ifdef _WIN32 - HFILE filehandle; - struct _BY_HANDLE_FILE_INFORMATION fileinfo; +#ifdef H5_HAVE_WIN32_API + HFILE filehandle; + struct _BY_HANDLE_FILE_INFORMATION fileinfo; int fd; -#else /* _WIN32 */ - struct stat sb; -#endif /* _WIN32 */ +#else /* H5_HAVE_WIN32_API */ + struct stat sb; +#endif /* H5_HAVE_WIN32_API */ /* Sanity check on file offsets */ assert(sizeof(file_offset_t)>=sizeof(size_t)); @@ -412,7 +406,7 @@ H5FD_stdio_open( const char *name, unsigned flags, hid_t fapl_id, } /* The unique key */ -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API /*#error "Needs correct fileindexhi & fileindexlo, code below is from sec2 driver"*/ fd = _fileno(f); filehandle = _get_osfhandle(fd); @@ -434,17 +428,17 @@ H5FD_stdio_open( const char *name, unsigned flags, hid_t fapl_id, /*------------------------------------------------------------------------- - * Function: H5F_stdio_close + * Function: H5F_stdio_close * - * Purpose: Closes a file. + * Purpose: Closes a file. * * Errors: - * IO CLOSEERROR Fclose failed. + * IO CLOSEERROR Fclose failed. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Wednesday, October 22, 1997 + * Programmer: Robb Matzke + * Wednesday, October 22, 1997 * * Modifications: * Ported to VFL/H5FD layer - QAK, 10/18/99 @@ -454,7 +448,7 @@ H5FD_stdio_open( const char *name, unsigned flags, hid_t fapl_id, static herr_t H5FD_stdio_close(H5FD_t *_file) { - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; + H5FD_stdio_t *file = (H5FD_stdio_t*)_file; static const char *func="H5FD_stdio_close"; /* Function Name for error reporting */ /* Clear the error stack */ @@ -470,17 +464,17 @@ H5FD_stdio_close(H5FD_t *_file) /*------------------------------------------------------------------------- - * Function: H5FD_stdio_cmp + * Function: H5FD_stdio_cmp * - * Purpose: Compares two files belonging to this driver using an - * arbitrary (but consistent) ordering. + * Purpose: Compares two files belonging to this driver using an + * arbitrary (but consistent) ordering. * - * Return: Success: A value like strcmp() + * Return: Success: A value like strcmp() * - * Failure: never fails (arguments were checked by the - * caller). + * Failure: never fails (arguments were checked by the + * caller). * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: @@ -491,13 +485,13 @@ H5FD_stdio_close(H5FD_t *_file) static int H5FD_stdio_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_stdio_t *f1 = (const H5FD_stdio_t*)_f1; - const H5FD_stdio_t *f2 = (const H5FD_stdio_t*)_f2; + const H5FD_stdio_t *f1 = (const H5FD_stdio_t*)_f1; + const H5FD_stdio_t *f2 = (const H5FD_stdio_t*)_f2; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API if (f1->fileindexhi < f2->fileindexhi) return -1; if (f1->fileindexhi > f2->fileindexhi) return 1; @@ -525,16 +519,16 @@ H5FD_stdio_cmp(const H5FD_t *_f1, const H5FD_t *_f2) /*------------------------------------------------------------------------- - * Function: H5FD_stdio_query + * Function: H5FD_stdio_query * - * Purpose: Set the flags that this VFL driver is capable of supporting. + * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) * - * Return: Success: non-negative + * Return: Success: non-negative * - * Failure: negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Friday, August 25, 2000 * * Modifications: @@ -561,18 +555,18 @@ H5FD_stdio_query(const H5FD_t *_f, unsigned long *flags /* out */) /*------------------------------------------------------------------------- - * Function: H5FD_stdio_alloc + * Function: H5FD_stdio_alloc * - * Purpose: Allocates file memory. If fseeko isn't available, makes + * Purpose: Allocates file memory. If fseeko isn't available, makes * sure the file size isn't bigger than 2GB because the * parameter OFFSET of fseek is of the type LONG INT, limiting * the file size to 2GB. * - * Return: Success: Address of new memory + * Return: Success: Address of new memory * - * Failure: HADDR_UNDEF + * Failure: HADDR_UNDEF * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * 30 March 2007 * * Modifications: @@ -582,8 +576,8 @@ H5FD_stdio_query(const H5FD_t *_f, unsigned long *flags /* out */) static haddr_t H5FD_stdio_alloc(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxpl_id, hsize_t size) { - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; - haddr_t addr; + H5FD_stdio_t *file = (H5FD_stdio_t*)_file; + haddr_t addr; haddr_t ret_value; /* Return value */ /* Shut compiler up */ @@ -613,17 +607,17 @@ H5FD_stdio_alloc(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxp /*------------------------------------------------------------------------- - * Function: H5FD_stdio_get_eoa + * Function: H5FD_stdio_get_eoa * - * Purpose: Gets the end-of-address marker for the file. The EOA marker - * is the first address past the last byte allocated in the - * format address space. + * Purpose: Gets the end-of-address marker for the file. The EOA marker + * is the first address past the last byte allocated in the + * format address space. * - * Return: Success: The end-of-address marker. + * Return: Success: The end-of-address marker. * - * Failure: HADDR_UNDEF + * Failure: HADDR_UNDEF * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, August 2, 1999 * * Modifications: @@ -638,7 +632,7 @@ H5FD_stdio_alloc(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxp static haddr_t H5FD_stdio_get_eoa(const H5FD_t *_file, H5FD_mem_t /*unused*/ type) { - const H5FD_stdio_t *file = (const H5FD_stdio_t *)_file; + const H5FD_stdio_t *file = (const H5FD_stdio_t *)_file; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -651,17 +645,17 @@ H5FD_stdio_get_eoa(const H5FD_t *_file, H5FD_mem_t /*unused*/ type) /*------------------------------------------------------------------------- - * Function: H5FD_stdio_set_eoa + * Function: H5FD_stdio_set_eoa * - * Purpose: Set the end-of-address marker for the file. This function is - * called shortly after an existing HDF5 file is opened in order - * to tell the driver where the end of the HDF5 data is located. + * Purpose: Set the end-of-address marker for the file. This function is + * called shortly after an existing HDF5 file is opened in order + * to tell the driver where the end of the HDF5 data is located. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: @@ -675,7 +669,7 @@ H5FD_stdio_get_eoa(const H5FD_t *_file, H5FD_mem_t /*unused*/ type) static herr_t H5FD_stdio_set_eoa(H5FD_t *_file, H5FD_mem_t /*unused*/ type, haddr_t addr) { - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; + H5FD_stdio_t *file = (H5FD_stdio_t*)_file; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -690,19 +684,19 @@ H5FD_stdio_set_eoa(H5FD_t *_file, H5FD_mem_t /*unused*/ type, haddr_t addr) /*------------------------------------------------------------------------- - * Function: H5FD_stdio_get_eof + * Function: H5FD_stdio_get_eof * - * Purpose: Returns the end-of-file marker, which is the greater of - * either the Unix end-of-file or the HDF5 end-of-address - * markers. + * Purpose: Returns the end-of-file marker, which is the greater of + * either the Unix end-of-file or the HDF5 end-of-address + * markers. * - * Return: Success: End of file address, the first address past - * the end of the "file", either the Unix file - * or the HDF5 file. + * Return: Success: End of file address, the first address past + * the end of the "file", either the Unix file + * or the HDF5 file. * - * Failure: HADDR_UNDEF + * Failure: HADDR_UNDEF * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: @@ -713,7 +707,7 @@ H5FD_stdio_set_eoa(H5FD_t *_file, H5FD_mem_t /*unused*/ type, haddr_t addr) static haddr_t H5FD_stdio_get_eof(const H5FD_t *_file) { - const H5FD_stdio_t *file = (const H5FD_stdio_t *)_file; + const H5FD_stdio_t *file = (const H5FD_stdio_t *)_file; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -756,24 +750,24 @@ H5FD_stdio_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle) /*------------------------------------------------------------------------- - * Function: H5F_stdio_read + * Function: H5F_stdio_read * - * Purpose: Reads SIZE bytes beginning at address ADDR in file LF and - * places them in buffer BUF. Reading past the logical or - * physical end of file returns zeros instead of failing. + * Purpose: Reads SIZE bytes beginning at address ADDR in file LF and + * places them in buffer BUF. Reading past the logical or + * physical end of file returns zeros instead of failing. * * Errors: - * IO READERROR Fread failed. - * IO SEEKERROR Fseek failed. + * IO READERROR Fread failed. + * IO SEEKERROR Fseek failed. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Wednesday, October 22, 1997 + * Programmer: Robb Matzke + * Wednesday, October 22, 1997 * * Modifications: - * June 2, 1998 Albert Cheng - * Added xfer_mode argument + * June 2, 1998 Albert Cheng + * Added xfer_mode argument * * Ported to VFL/H5FD layer - QAK, 10/18/99 * @@ -783,8 +777,8 @@ static herr_t H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *buf/*out*/) { - size_t n; - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; + size_t n; + H5FD_stdio_t *file = (H5FD_stdio_t*)_file; static const char *func="H5FD_stdio_read"; /* Function Name for error reporting */ /* Shut compiler up */ @@ -862,23 +856,23 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, siz /*------------------------------------------------------------------------- - * Function: H5F_stdio_write + * Function: H5F_stdio_write * - * Purpose: Writes SIZE bytes from the beginning of BUF into file LF at - * file address ADDR. + * Purpose: Writes SIZE bytes from the beginning of BUF into file LF at + * file address ADDR. * * Errors: - * IO SEEKERROR Fseek failed. - * IO WRITEERROR Fwrite failed. + * IO SEEKERROR Fseek failed. + * IO WRITEERROR Fwrite failed. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Wednesday, October 22, 1997 + * Programmer: Robb Matzke + * Wednesday, October 22, 1997 * * Modifications: - * June 2, 1998 Albert Cheng - * Added xfer_mode argument + * June 2, 1998 Albert Cheng + * Added xfer_mode argument * * Ported to VFL/H5FD layer - QAK, 10/18/99 * @@ -886,9 +880,9 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, siz */ static herr_t H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, - size_t size, const void *buf) + size_t size, const void *buf) { - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; + H5FD_stdio_t *file = (H5FD_stdio_t*)_file; static const char *func="H5FD_stdio_write"; /* Function Name for error reporting */ /* Shut compiler up */ @@ -945,25 +939,25 @@ H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, /*------------------------------------------------------------------------- - * Function: H5F_stdio_flush + * Function: H5F_stdio_flush * - * Purpose: Makes sure that all data is on disk. + * Purpose: Makes sure that all data is on disk. * * Errors: - * IO SEEKERROR fseek failed. - * IO WRITEERROR fflush or fwrite failed. + * IO SEEKERROR fseek failed. + * IO WRITEERROR fflush or fwrite failed. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Wednesday, October 22, 1997 + * Programmer: Robb Matzke + * Wednesday, October 22, 1997 * *------------------------------------------------------------------------- */ static herr_t H5FD_stdio_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing) { - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; + H5FD_stdio_t *file = (H5FD_stdio_t*)_file; static const char *func = "H5FD_stdio_flush"; /* Function Name for error reporting */ /* Shut compiler up */ @@ -990,29 +984,29 @@ H5FD_stdio_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing) /*------------------------------------------------------------------------- - * Function: H5F_stdio_truncate + * Function: H5F_stdio_truncate * - * Purpose: Makes sure that the true file size is the same (or larger) - * than the end-of-address. + * Purpose: Makes sure that the true file size is the same (or larger) + * than the end-of-address. * * Errors: - * IO SEEKERROR fseek failed. - * IO WRITEERROR fflush or fwrite failed. + * IO SEEKERROR fseek failed. + * IO WRITEERROR fflush or fwrite failed. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * Thursday, January 31, 2008 + * Programmer: Quincey Koziol + * Thursday, January 31, 2008 * * Modifications: - * Vailin Choi; June 2010 - * Fix for window failures manifested from tests in mf.c. + * Vailin Choi; June 2010 + * Fix for window failures manifested from tests in mf.c. *------------------------------------------------------------------------- */ static herr_t H5FD_stdio_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) { - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; + H5FD_stdio_t *file = (H5FD_stdio_t*)_file; static const char *func = "H5FD_stdio_truncate"; /* Function Name for error reporting */ /* Shut compiler up */ @@ -1028,11 +1022,11 @@ H5FD_stdio_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) if(file->eoa != file->eof) { int fd = fileno(file->fp); /* File descriptor for HDF5 file */ -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API HFILE filehandle; /* Windows file handle */ LARGE_INTEGER li; /* 64-bit integer for SetFilePointer() call */ - /* Reset seek offset to beginning of file, so that file isn't re-extended later */ + /* Reset seek offset to beginning of file, so that file isn't re-extended later */ rewind(file->fp); /* Map the posix file handle to a Windows file handle */ @@ -1044,14 +1038,14 @@ H5FD_stdio_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) (void)SetFilePointer((HANDLE)filehandle, li.LowPart, &li.HighPart, FILE_BEGIN); if(SetEndOfFile((HANDLE)filehandle) == 0) H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "unable to truncate/extend file properly", -1) -#else /* _WIN32 */ +#else /* H5_HAVE_WIN32_API */ /* Reset seek offset to beginning of file, so that file isn't re-extended later */ rewind(file->fp); /* Truncate file to proper length */ if(-1 == file_ftruncate(fd, (file_offset_t)file->eoa)) H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "unable to truncate/extend file properly", -1) -#endif /* _WIN32 */ +#endif /* H5_HAVE_WIN32_API */ /* Update the eof value */ file->eof = file->eoa; |