From c18c569198187bfdbc0527eb0b7c1aad147c3068 Mon Sep 17 00:00:00 2001 From: Patrick Lu Date: Mon, 30 Aug 1999 09:33:17 -0500 Subject: [svn-r1614] put a #ifdef HAVE_UNISTD_H around the #include for the it. since on NT I took out the device and inode members in the H5FD_sec2_t and replaced them with 2 fields more appropriate for NT I had to replace all occurences of the device and inode with the correct member --- src/H5FDsec2.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index 1098dc3..f002c5f 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -18,7 +18,13 @@ #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif +#ifdef WIN32 +#include +#endif + #undef MAX @@ -236,7 +242,11 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id/*unused*/, int fd; struct stat sb; H5FD_sec2_t *file=NULL; - +#ifdef WIN32 + HFILE filehandle; + struct _BY_HANDLE_FILE_INFORMATION fileinfo; + int results; +#endif /* Check arguments */ if (!name || !*name) return NULL; if (0==maxaddr || HADDR_UNDEF==maxaddr) return NULL; @@ -247,8 +257,13 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id/*unused*/, if (H5F_ACC_TRUNC & flags) o_flags |= O_TRUNC; if (H5F_ACC_CREAT & flags) o_flags |= O_CREAT; if (H5F_ACC_EXCL & flags) o_flags |= O_EXCL; - +#ifdef WIN32 + /*this is included since we aren't using HDopen which would + normally include this flag for us*/ + o_flags |= O_BINARY; +#endif /* Open the file */ + if ((fd=open(name, o_flags, 0666))<0) return NULL; if (fstat(fd, &sb)<0) { close(fd); @@ -261,9 +276,15 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id/*unused*/, file->eof = sb.st_size; file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; +#ifdef WIN32 + filehandle = _get_osfhandle(fd); + results = GetFileInformationByHandle(filehandle, &fileinfo); + file->fileindexhi = fileinfo.nFileIndexHigh; + file->fileindexlo = fileinfo.nFileIndexLow; +#else file->device = sb.st_dev; file->inode = sb.st_ino; - +#endif return (H5FD_t*)file; } @@ -319,13 +340,20 @@ H5FD_sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { const H5FD_sec2_t *f1 = (const H5FD_sec2_t*)_f1; const H5FD_sec2_t *f2 = (const H5FD_sec2_t*)_f2; +#ifdef WIN32 + if (f1->fileindexhi < f2->fileindexhi) return -1; + if (f1->fileindexhi > f2->fileindexhi) return 1; + + if (f1->fileindexlo < f2->fileindexlo) return -1; + if (f1->fileindexlo > f2->fileindexlo) return 1; +#else if (f1->device < f2->device) return -1; if (f1->device > f2->device) return 1; if (f1->inode < f2->inode) return -1; if (f1->inode > f2->inode) return 1; - +#endif return 0; } -- cgit v0.12