Windows 7 64 ビット、mingw でコンパイル。Windows ヘッダーで GetFileAttributesA を使用して、特定のパスがディレクトリであるかどうかをテストしようとしています。ディレクトリである何かの定数は 16 です。ただし、何らかの理由で 17 が返されます。私のコードは次のようになります。
#include <iostream>
#include <windows.h>
void dir_exists(std::string dir_path)
{
DWORD f_attrib = GetFileAttributesA(dir_path.c_str());
std::cout << "Current: " << f_attrib << std::endl <<
"Wanted: " <<
FILE_ATTRIBUTE_DIRECTORY << std::endl;
}
int main()
{
dir_exists("C:\\Users\\");
return 0;
}
これを実行すると、出力は次のようになります。
Current: 17
Wanted: 16
Current は 16 を返すはずです。トピックで述べたように、ドキュメントで 17 が何を意味するかについての言及を見つけることさえできません。