X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fbook.cpp;h=2c11a3d507b066db136e23e916257368d6e51291;hb=1e7aaed8bc;hp=7cb0863c11158b2f414a0c2868d0a8041b5b3cf9;hpb=bdfd656c2400ea66cfdbd7dae9ca6bfd505e91c7;p=stockfish diff --git a/src/book.cpp b/src/book.cpp index 7cb0863c..2c11a3d5 100644 --- a/src/book.cpp +++ b/src/book.cpp @@ -30,6 +30,7 @@ //// #include +#include #include "book.h" #include "movegen.h" @@ -365,18 +366,20 @@ void Book::open(const string& fName) { fileName = fName; ifstream::open(fileName.c_str(), ifstream::in | ifstream::binary); - if (is_open()) - { - // Get the book size in number of entries - seekg(0, ios::end); - bookSize = long(tellg()) / EntrySize; - seekg(0, ios::beg); + // Silently return when asked to open a non-exsistent file + if (!is_open()) + return; + + // Get the book size in number of entries + seekg(0, ios::end); + bookSize = long(tellg()) / EntrySize; + seekg(0, ios::beg); - if (good()) - return; + if (!good()) + { + cerr << "Failed to open book file " << fileName << endl; + exit(EXIT_FAILURE); } - cerr << "Failed to open book file " << fileName << endl; - Application::exit_with_failure(); } @@ -496,7 +499,7 @@ void Book::read_entry(BookEntry& entry, int idx) { if (!good()) { cerr << "Failed to read book entry at index " << idx << endl; - Application::exit_with_failure(); + exit(EXIT_FAILURE); } }