The reason this fails is because obtaining attributes about the file would be a security vulnerability. I believe the reason this fails is because this function wraps GetFileSize from the Win32 API.
Checking for the file existence specifically can be done using the C++ sys/stat.h library (I believe this is part of the STL) and should work even if the user has no access:
Code: Select all
bool fileExist(const string fileName)
{
struct stat fileInfo;
int statistics;
// Attempt to get the file attributes
statistics = stat(fileName.c_str(), &fileInfo);
return !statistics; // Returns true/false if file exists
}