File::existsAsFile() over 2GB


#1

On my 32-bit Arch Linux installs, File::existsAsFile() returns false for files that are larger than 2 GB.

I test on a file that I previously found by getting a directory list, the file is really there, and I was just testing it wasn’t a folder before asking FFPMEG to open it (by path). I was very confused when the code stopped working, and they debugger got me to this issue. Removing the test and just opening it was a simple workaround.

Bruce


#2

damn! sounds like lstat() is failing… Does it help if you go in juce_posix_SharedCode.h and change it so that the linux build uses lstat64, i.e. hack the #ifdefs like this:

#if JUCE_LINUX || (JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T) && (lstat64 (fullPath.toUTF8(), &info) == 0); #else && (lstat (fullPath.toUTF8(), &info) == 0); #endif
?


#3

That didn’t build:

cannot convert ‘juce::{anonymous}::juce_statStruct*’ to ‘stat64*’

If I changed the struct define (throughout), what would break?

EDIT - I guess that’s what you meant. Yes - a cursory look says it fixes that specific bug. Can’t say what else gets affected.

Bruce


#4

Thanks Bruce - yes, I’ll change it all to use stat64 on linux. I didn’t do so before because in OSX stat64 is deprecated (its normal stat is already 64-bit) and I kind of assumed other posix systems would be the same. I guess not.


#5

use -DLARGE_FILE_OFFSET -D_LFS and it’ll work unmodified.
stat would then point to stat64 and so do lstat.