Commit 78ccc605 authored by Olivier Bertrand's avatar Olivier Bertrand

Fix compile error on LINUX (LARGE_INTEGER)

parent 28af4212
......@@ -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
......
......@@ -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);
......
......@@ -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);
......
......@@ -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
/*****************************************************************/
......
......@@ -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);
......
......@@ -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));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment