diff options
author | MuQun Yang <ymuqun@hdfgroup.org> | 2000-12-22 18:54:16 (GMT) |
---|---|---|
committer | MuQun Yang <ymuqun@hdfgroup.org> | 2000-12-22 18:54:16 (GMT) |
commit | 00d05eb3dff80daa71cd91e1c68ff236546446de (patch) | |
tree | 377f1d6d8686cce4fbb037c3fcb6ef89fc89bdff | |
parent | 6ff667c0daefc3d29921f9a23884c8ae9f6e8f4c (diff) | |
download | hdf5-00d05eb3dff80daa71cd91e1c68ff236546446de.zip hdf5-00d05eb3dff80daa71cd91e1c68ff236546446de.tar.gz hdf5-00d05eb3dff80daa71cd91e1c68ff236546446de.tar.bz2 |
[svn-r3191]
Purpose:
a windows bug fix
Description:
support > 2G file on windows NTFS
Solution:
using fsetpos to seek the address
Platforms tested:
windows 2000, confirmed on arabica and eirene.
-rw-r--r-- | src/H5FDstdio.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index 0686277..6dd5337 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -100,11 +100,23 @@ typedef struct H5FD_stdio_t { * which can be addressed entirely by the second * argument of the file seek function. */ +/* adding for windows NT filesystem support. */ +#ifdef WIN32 +#define MAXADDR (((haddr_t)1<<(8*sizeof(LONGLONG)-1))-1) +#else #define MAXADDR (((haddr_t)1<<(8*sizeof(long)-1))-1) +#endif + #define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || ((A) & ~(haddr_t)MAXADDR)) #define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) + +#ifdef WIN32 +#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ + sizeof(LONGLONG)<sizeof(size_t) || HADDR_UNDEF==(A)+(Z) || (LONGLONG)((A)+(Z))<(LONGLONG)(A)) +#else #define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ sizeof(long)<sizeof(size_t) || HADDR_UNDEF==(A)+(Z) || (long)((A)+(Z))<(long)(A)) +#endif /* Prototypes */ static H5FD_t *H5FD_stdio_open(const char *name, unsigned flags, @@ -312,7 +324,7 @@ H5FD_stdio_open( const char *name, unsigned flags, hid_t fapl_id, /* The unique key */ #ifdef WIN32 -//#error "Needs correct fileindexhi & fileindexlo, code below is from sec2 driver" +/*#error "Needs correct fileindexhi & fileindexlo, code below is from sec2 driver"*/ filehandle = _get_osfhandle(f); results = GetFileInformationByHandle(filehandle, &fileinfo); file->fileindexhi = fileinfo.nFileIndexHigh; @@ -601,11 +613,21 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsi */ if (!(file->op == H5FD_STDIO_OP_READ || file->op==H5FD_STDIO_OP_SEEK) || file->pos != addr) { +#ifdef WIN32 + fpos_t tempos =(fpos_t)(addr+SEEK_SET); + if (fsetpos(file->fp,&tempos)!=0) { + file->op = H5FD_STDIO_OP_UNKNOWN; + file->pos = HADDR_UNDEF; + H5Epush_ret(func, H5E_IO, H5E_SEEKERROR, "fsetpos failed", -1); + } +#else + if (fseek(file->fp, (long)addr, SEEK_SET) < 0) { file->op = H5FD_STDIO_OP_UNKNOWN; file->pos = HADDR_UNDEF; H5Epush_ret(func, H5E_IO, H5E_SEEKERROR, "fseek failed", -1); } +#endif file->pos = addr; } @@ -691,11 +713,13 @@ H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, */ if (!(file->op == H5FD_STDIO_OP_WRITE || file->op==H5FD_STDIO_OP_SEEK) || file->pos != addr) { +#ifdef WIN32 fpos_t tempos =(fpos_t)(addr+SEEK_SET); if (fsetpos(file->fp,&tempos)!=0) { file->op = H5FD_STDIO_OP_UNKNOWN; file->pos = HADDR_UNDEF; H5Epush_ret(func, H5E_IO, H5E_SEEKERROR, "fsetpos failed", -1); } #else if (fseek(file->fp, (long)addr, SEEK_SET) < 0) { file->op = H5FD_STDIO_OP_UNKNOWN; file->pos = HADDR_UNDEF; H5Epush_ret(func, H5E_IO, H5E_SEEKERROR, "fseek failed", -1); } +#endif file->pos = addr; } |