| 1 | #include <util/file.hh> |
| 2 | #include <fstream> |
| 3 | #include <cassert> |
| 4 | |
| 5 | std::vector<char> readFile(const std::string &filename) { |
| 6 | std::ifstream file(filename, std::ios::ate | std::ios::binary); |
| 7 | if (!file.is_open()) { |
| 8 | assert(false && u8"ファイルを開くに失敗。"); |
| 9 | return {}; |
| 10 | } |
| 11 | |
| 12 | size_t fileSize = (size_t)file.tellg(); |
| 13 | std::vector<char> buf(fileSize); |
| 14 | file.seekg(0); |
| 15 | file.read(buf.data(), fileSize); |
| 16 | file.close(); |
| 17 | return buf; |
| 18 | } |