| 73 | } |
| 74 | |
| 75 | void loadFromFile(std::string const& fileName, char* dst, size_t size) |
| 76 | { |
| 77 | ASSERT(dst); |
| 78 | |
| 79 | std::ifstream file(fileName, std::ios::in | std::ios::binary); |
| 80 | if (file.is_open()) |
| 81 | { |
| 82 | file.read(dst, size); |
| 83 | size_t const nbBytesRead = file.gcount(); |
| 84 | file.close(); |
| 85 | if (nbBytesRead != size) |
| 86 | { |
| 87 | std::ostringstream msg; |
| 88 | msg << "Unexpected file size for input file: " << fileName << ". Note: Expected: " << size |
| 89 | << " bytes but only read: " << nbBytesRead << " bytes"; |
| 90 | throw std::invalid_argument(msg.str()); |
| 91 | } |
| 92 | } |
| 93 | else |
| 94 | { |
| 95 | std::ostringstream msg; |
| 96 | msg << "Cannot open file " << fileName << "!"; |
| 97 | throw std::invalid_argument(msg.str()); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | std::vector<std::string> splitToStringVec(std::string const& s, char separator) |
| 102 | { |
no test coverage detected