06-05-2019 02:50 PM
Hello,
I am using GetFileSize function to read a file size, and I think I am running into the dreaded 2 gb file size limit for 32 bit applications, since this works for all files below 2 gb. I am using the 64 bit debug as the build but when attempt to get the size for a large file (2,278,153,276 bytes) I get an error:
NON-FATAL RUN-TIME ERROR: Function CVI_GetFileSize: (return value == -3 [0xfffffffffffffffd]).
|
In my code:
static char file_nameEDF[MAX_PATHNAME_LEN];
ssize_t size64;
if(FileSelectPopup ("", "*.edf", "*.edf","Name of File to Read", VAL_LOAD_BUTTON, 0, 0, 1, 1, file_nameEDF)>0){
GetFileSize(file_nameEDF, &size64);
}
Is there another function I should be using?
Thank you,
06-06-2019 04:33 AM
GetFileSizeEx from the Win32API should do the trick:
#include <windows.h>
__int64 size64;
HANDLE hFile;
hFile = CreateFile(file, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
GetFileSizeEx (hFile, (PLARGE_INTEGER)&size64);
DebugPrintf ("File size is %I64d bytes\n", size64);
CloseHandle (hFile);
06-06-2019 05:06 AM
As an alternative, if you do not want to actually open the file, try this:
#include <windows.h>
WIN32_FILE_ATTRIBUTE_DATA fAttrData;
LARGE_INTEGER size64;
GetFileAttributesEx (
file, //__in LPCTSTR lpFileName,
GetFileExInfoStandard, //__in GET_FILEEX_INFO_LEVELS fInfoLevelId,
&fAttrData //__out LPVOID lpFileInformation
);
size64.u.LowPart = fAttrData.nFileSizeLow;
size64.u.HighPart = fAttrData.nFileSizeHigh;
DebugPrintf ("File size is %I64d bytes\n", size64.QuadPart);