How to get the file size of a file in C when the file size exceeds 4 GB?
ftell returns 4 bytes, signed long, limiting it to two bytes. stat has a variable of type off_t, which is also 4 bytes (not sure of the sign), so it can tell me the size of the 4gb file.
What if the file is larger than 4 GB?
On Linux with glibc, ftell returns off_t; depending on the flags, there off_tmay be 32 bits or there may be 64 bits.
off_t
On Linux, you can get the appropriate flags for 64-bit off_tby doing getconf LFS_CFLAGS(LFS means large file support).
getconf LFS_CFLAGS
Windows GetFileSize[Ex] , .
GetFileSize[Ex]
to try
#define _LARGEFILE64_SOURCE 1 #define _FILE_OFFSET_BITS 64
I think that increases the size of off_t to 64 bits on some operating systems
Source: https://habr.com/ru/post/1744728/More articles:Naming convention for primary key in table - cakephpHow can I do such a typical unittest? - pythonEmail Functionality for Public Website - htmlThe sum of all primes up to 2 million - c ++Scala internal compilation. Working with interactive.Global - scalawhat buffer size is best for uploading a file to the Internet - httpdo not display notification after seeing that once - androidMvcContrib CheckBoxList - mvccontribjquery every () does not work in Internet Explorer - javascriptIs 2 + 3 considered a literal? - literalsAll Articles