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

Fix compile error on LINUX (LARGE_INTEGER)

parent 28af4212
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2005-2017 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2020 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -176,7 +176,11 @@ bool MAPFAM::OpenTableFile(PGLOBAL g) ...@@ -176,7 +176,11 @@ bool MAPFAM::OpenTableFile(PGLOBAL g)
/*******************************************************************/ /*******************************************************************/
/* Get the file size. */ /* 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; Memory = (char *)mm.memory;
if (!len) { // Empty or deleted file if (!len) { // Empty or deleted file
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2005-2017 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2020 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -1423,8 +1423,12 @@ bool VCMFAM::OpenTableFile(PGLOBAL g) ...@@ -1423,8 +1423,12 @@ bool VCMFAM::OpenTableFile(PGLOBAL g)
/*******************************************************************/ /*******************************************************************/
/* Get the file size. */ /* Get the file size. */
/*******************************************************************/ /*******************************************************************/
len = (size_t)mm.sz.QuadPart; len = (size_t)mm.lenL;
Memory = (char *)mm.memory;
if (mm.lenH)
len += ((size_t)mm.lenH * 0x000000001LL);
Memory = (char *)mm.memory;
if (!len) { // Empty or deleted file if (!len) { // Empty or deleted file
CloseFileHandle(hFile); CloseFileHandle(hFile);
...@@ -2816,8 +2820,12 @@ bool VMPFAM::MapColumnFile(PGLOBAL g, MODE mode, int i) ...@@ -2816,8 +2820,12 @@ bool VMPFAM::MapColumnFile(PGLOBAL g, MODE mode, int i)
/*****************************************************************/ /*****************************************************************/
/* Get the file size (assuming file is smaller than 4 GB) */ /* Get the file size (assuming file is smaller than 4 GB) */
/*****************************************************************/ /*****************************************************************/
len = (size_t)mm.sz.QuadPart; len = (size_t)mm.lenL;
Memcol[i] = (char *)mm.memory;
if (mm.lenH)
len += ((size_t)mm.lenH * 0x000000001LL);
Memcol[i] = (char *)mm.memory;
if (!len) { // Empty or deleted file if (!len) { // Empty or deleted file
CloseFileHandle(hFile); CloseFileHandle(hFile);
......
...@@ -1768,9 +1768,13 @@ static PJSON ParseJsonFile(PGLOBAL g, char *fn, int *pretty, size_t& len) ...@@ -1768,9 +1768,13 @@ static PJSON ParseJsonFile(PGLOBAL g, char *fn, int *pretty, size_t& len)
} // endif hFile } // 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; memory = (char *)mm.memory;
if (!len) { // Empty or deleted file if (!len) { // Empty or deleted file
...@@ -6041,11 +6045,16 @@ char* JUP::UnprettyJsonFile(PGLOBAL g, char *fn, char *outfn, int lrecl) { ...@@ -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) */ /* 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); CloseFileHandle(hFile);
return NULL; return NULL;
} else } else {
len = (size_t)mm.sz.QuadPart; len = (size_t)mm.lenL;
if (mm.lenH)
len += ((size_t)mm.lenH * 0x000000001LL);
} // endif size
if (!mm.memory) { if (!mm.memory) {
CloseFileHandle(hFile); CloseFileHandle(hFile);
......
...@@ -90,8 +90,8 @@ HANDLE CreateFileMap(PGLOBAL g, LPCSTR filename, ...@@ -90,8 +90,8 @@ HANDLE CreateFileMap(PGLOBAL g, LPCSTR filename,
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
} // endif memory } // endif memory
// HighPart is the high-order word of the file size // lenH is the high-order word of the file size
mm->sz.LowPart = GetFileSize(hFile, (LPDWORD)&mm->sz.HighPart); mm->lenL = GetFileSize(hFile, &mm->lenH);
CloseHandle(hFileMap); // Not used anymore CloseHandle(hFileMap); // Not used anymore
} else // MODE_INSERT } else // MODE_INSERT
/*****************************************************************/ /*****************************************************************/
......
...@@ -7,7 +7,8 @@ extern "C" { ...@@ -7,7 +7,8 @@ extern "C" {
typedef struct { typedef struct {
void *memory; void *memory;
LARGE_INTEGER sz; DWORD lenL;
DWORD lenH;
} MEMMAP; } MEMMAP;
DllExport HANDLE CreateFileMap(PGLOBAL, LPCSTR, MEMMAP *, MODE, bool); DllExport HANDLE CreateFileMap(PGLOBAL, LPCSTR, MEMMAP *, MODE, bool);
......
...@@ -2471,7 +2471,7 @@ void XFILE::Close(void) ...@@ -2471,7 +2471,7 @@ void XFILE::Close(void)
} // endif Xfile } // endif Xfile
#if defined(XMAP) #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"); printf("Error closing mapped index\n");
#endif // XMAP #endif // XMAP
} // end of Close } // end of Close
...@@ -2487,7 +2487,7 @@ void *XFILE::FileView(PGLOBAL g, char *fn) ...@@ -2487,7 +2487,7 @@ void *XFILE::FileView(PGLOBAL g, char *fn)
Mmp = (MMP)PlugSubAlloc(g, NULL, sizeof(MEMMAP)); Mmp = (MMP)PlugSubAlloc(g, NULL, sizeof(MEMMAP));
h = CreateFileMap(g, fn, Mmp, MODE_READ, false); 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)) if (!(*g->Message))
strcpy(g->Message, MSG(FILE_MAP_ERR)); 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