| 55 | } |
| 56 | |
| 57 | static std::string tryReadFile(std::string const& filename) { |
| 58 | std::string s; |
| 59 | std::ifstream ifs(filename.c_str(), std::ifstream::in); |
| 60 | |
| 61 | if (!ifs.is_open()) { |
| 62 | std::cerr << "Cannot open input file '" << filename << "'" << std::endl; |
| 63 | ::exit(EXIT_FAILURE); |
| 64 | } |
| 65 | |
| 66 | char buffer[4096]; |
| 67 | while (ifs.good()) { |
| 68 | ifs.read(&buffer[0], sizeof(buffer)); |
| 69 | s.append(buffer, ifs.gcount()); |
| 70 | } |
| 71 | ifs.close(); |
| 72 | |
| 73 | return s; |
| 74 | } |
| 75 | |
| 76 | static std::string readFile(std::string filename) { |
| 77 | #ifdef _WIN32 |