GetFileAttributeEx behavior is different than _stat.
For example if file out.txt exist, then GetFileAttributeEx returns success for
file argument "out.txt::$DATA" while it fails for stat.
#include <windows.h>
#include <iostream>
#include <sys/types.h>
#include <sys/stat.h>
using namespace std;
int main(int argc, char** argv)
{
WIN32_FILE_ATTRIBUTE_DATA findFileData;
char* fn = argv[1];
struct stat buf;
if (argc < 2) {
cout << "provide file name as argument\n";
return -1;
}
if (!GetFileAttributesEx(fn, GetFileExInfoStandard, &;;findFileData)) {
cout << "GetFileAttributesEx failed\n";
}
else {
cout << "GetFileAttributesEx succeeded\n";
}
if (stat(fn, &;;buf) != 0) {
cout << "stat failed\n";
}
else {
cout << "stat succeeded\n";
}
return 0;
}
F:\>main1 out.txt::$DATA
main1 out.txt::$DATA
GetFileAttributesEx succeeded
stat failed
----------------------------------------------------------
So what exactly are the differences between _stat and GetFileAttributesEx