I knew that I should never have used C ++ io, the whole argument “security type” is a red herring (does anyone really think that this is one of the most pressing problems?). In any case, I did this, and discovered a strange difference between ifstream and FILE * s and old file descriptors: ifstreams cannot read from the device. Can anyone think of a reason?
const char* path = "/dev/disk3";
char b;
FILE* f= fopen(path, "rb");
int i = fread(&b, 1, 1, f);
ifstream cf(path, ios::binary);
cf.read(&b, 1);
bool good = cf.good();
source
share