I have a 4 GB (exactly) file on an NTFS partition and a program that tries to get its size with stat() but it always fails with Unknown error (stat returns -1).
Does this mean that NTFS doesn't support 4 GB files? Or I have to use a different (Win32?) API?
Edit:
struct stat st;
if (stat(path.c_str(), &st) == -1) {
printf("stat: %s\n", strerror(errno));
}
outputs:
stat: Unknown error
The stat function returns a stat struct that defines the file size with 32 bits, which means it can handle correctly file sizes only up to 4GB. You should use stat64.
See also the stat function family on MSDN
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With