>>>> if(file.is_open()) {
In case I am wrong and you were using std::basic_ifstream but nevertheless don't have is_open member function you simply could do
std::ifstream file("o", ios::binary | ios::ate);
if(file) { ...
In case of an open error the ifstream sets the fail-bit what could be checked by
if (file)
Note, if using old ifstream the latter won't work. You then have to check for the fail-bit, e. g. by
if (!file.good())