From 78ccc605a56d9f6d7a7fd4dc8bc1003145ec3901 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Tue, 3 Nov 2020 23:19:22 +0100 Subject: [PATCH] Fix compile error on LINUX (LARGE_INTEGER) --- storage/connect/filamap.cpp | 8 ++++++-- storage/connect/filamvct.cpp | 18 +++++++++++++----- storage/connect/jsonudf.cpp | 19 ++++++++++++++----- storage/connect/maputil.cpp | 4 ++-- storage/connect/maputil.h | 3 ++- storage/connect/xindex.cpp | 4 ++-- 6 files changed, 39 insertions(+), 17 deletions(-) diff --git a/storage/connect/filamap.cpp b/storage/connect/filamap.cpp index 66cf081e5af..007968e0d44 100644 --- a/storage/connect/filamap.cpp +++ b/storage/connect/filamap.cpp @@ -5,7 +5,7 @@ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 2005-2017 */ +/* (C) Copyright to the author Olivier BERTRAND 2005-2020 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -176,7 +176,11 @@ bool MAPFAM::OpenTableFile(PGLOBAL g) /*******************************************************************/ /* Get the file size. */ /*******************************************************************/ - len = (size_t)mm.sz.QuadPart; + len = (size_t)mm.lenL; + + if (mm.lenH) + len += ((size_t)mm.lenH * 0x000000001LL); + Memory = (char *)mm.memory; if (!len) { // Empty or deleted file diff --git a/storage/connect/filamvct.cpp b/storage/connect/filamvct.cpp index bf4ef8557ad..5a3e025cd55 100644 --- a/storage/connect/filamvct.cpp +++ b/storage/connect/filamvct.cpp @@ -5,7 +5,7 @@ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 2005-2017 */ +/* (C) Copyright to the author Olivier BERTRAND 2005-2020 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -1423,8 +1423,12 @@ bool VCMFAM::OpenTableFile(PGLOBAL g) /*******************************************************************/ /* Get the file size. */ /*******************************************************************/ - len = (size_t)mm.sz.QuadPart; - Memory = (char *)mm.memory; + len = (size_t)mm.lenL; + + if (mm.lenH) + len += ((size_t)mm.lenH * 0x000000001LL); + + Memory = (char *)mm.memory; if (!len) { // Empty or deleted file CloseFileHandle(hFile); @@ -2816,8 +2820,12 @@ bool VMPFAM::MapColumnFile(PGLOBAL g, MODE mode, int i) /*****************************************************************/ /* Get the file size (assuming file is smaller than 4 GB) */ /*****************************************************************/ - len = (size_t)mm.sz.QuadPart; - Memcol[i] = (char *)mm.memory; + len = (size_t)mm.lenL; + + if (mm.lenH) + len += ((size_t)mm.lenH * 0x000000001LL); + + Memcol[i] = (char *)mm.memory; if (!len) { // Empty or deleted file CloseFileHandle(hFile); diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp index 6354b92107a..6c334111db0 100644 --- a/storage/connect/jsonudf.cpp +++ b/storage/connect/jsonudf.cpp @@ -1768,9 +1768,13 @@ static PJSON ParseJsonFile(PGLOBAL g, char *fn, int *pretty, size_t& len) } // endif hFile /*******************************************************************************/ - /* Get the file size (assuming file is smaller than 4 GB) */ + /* Get the file size. */ /*******************************************************************************/ - len = (size_t)mm.sz.QuadPart; + len = (size_t)mm.lenL; + + if (mm.lenH) + len += ((size_t)mm.lenH * 0x000000001LL); + memory = (char *)mm.memory; if (!len) { // Empty or deleted file @@ -6041,11 +6045,16 @@ char* JUP::UnprettyJsonFile(PGLOBAL g, char *fn, char *outfn, int lrecl) { /*******************************************************************************/ /* Get the file size (assuming file is smaller than 4 GB) */ /*******************************************************************************/ - if (!mm.sz.QuadPart) { // Empty or deleted file + if (!mm.lenL && !mm.lenH) { // Empty or deleted file CloseFileHandle(hFile); return NULL; - } else - len = (size_t)mm.sz.QuadPart; + } else { + len = (size_t)mm.lenL; + + if (mm.lenH) + len += ((size_t)mm.lenH * 0x000000001LL); + + } // endif size if (!mm.memory) { CloseFileHandle(hFile); diff --git a/storage/connect/maputil.cpp b/storage/connect/maputil.cpp index 86300f17200..87263b3adf6 100644 --- a/storage/connect/maputil.cpp +++ b/storage/connect/maputil.cpp @@ -90,8 +90,8 @@ HANDLE CreateFileMap(PGLOBAL g, LPCSTR filename, return INVALID_HANDLE_VALUE; } // endif memory - // HighPart is the high-order word of the file size - mm->sz.LowPart = GetFileSize(hFile, (LPDWORD)&mm->sz.HighPart); + // lenH is the high-order word of the file size + mm->lenL = GetFileSize(hFile, &mm->lenH); CloseHandle(hFileMap); // Not used anymore } else // MODE_INSERT /*****************************************************************/ diff --git a/storage/connect/maputil.h b/storage/connect/maputil.h index fd62fbcfeae..e310488eb5d 100644 --- a/storage/connect/maputil.h +++ b/storage/connect/maputil.h @@ -7,7 +7,8 @@ extern "C" { typedef struct { void *memory; - LARGE_INTEGER sz; + DWORD lenL; + DWORD lenH; } MEMMAP; DllExport HANDLE CreateFileMap(PGLOBAL, LPCSTR, MEMMAP *, MODE, bool); diff --git a/storage/connect/xindex.cpp b/storage/connect/xindex.cpp index 4d0f198705a..95f038d494c 100644 --- a/storage/connect/xindex.cpp +++ b/storage/connect/xindex.cpp @@ -2471,7 +2471,7 @@ void XFILE::Close(void) } // endif Xfile #if defined(XMAP) - if (Mmp && CloseMemMap(Mmp->memory, (size_t)Mmp->sz.QuadPart)) + if (Mmp && CloseMemMap(Mmp->memory, Mmp->lenL)) printf("Error closing mapped index\n"); #endif // XMAP } // end of Close @@ -2487,7 +2487,7 @@ void *XFILE::FileView(PGLOBAL g, char *fn) Mmp = (MMP)PlugSubAlloc(g, NULL, sizeof(MEMMAP)); h = CreateFileMap(g, fn, Mmp, MODE_READ, false); - if (h == INVALID_HANDLE_VALUE || (!Mmp->sz.QuadPart)) { + if (h == INVALID_HANDLE_VALUE || (!Mmp->lenH && !Mmp->lenL)) { if (!(*g->Message)) strcpy(g->Message, MSG(FILE_MAP_ERR));