Read the contents of a file into an array of char
| 81 | |
| 82 | // Read the contents of a file into an array of char |
| 83 | bool getFileContents(const std::filesystem::path& filename, std::vector<char>& buffer) |
| 84 | { |
| 85 | if (auto file = std::ifstream(filename, std::ios_base::binary)) |
| 86 | { |
| 87 | file.seekg(0, std::ios_base::end); |
| 88 | const std::ifstream::pos_type size = file.tellg(); |
| 89 | if (size > 0) |
| 90 | { |
| 91 | file.seekg(0, std::ios_base::beg); |
| 92 | buffer.resize(static_cast<std::size_t>(size)); |
| 93 | file.read(buffer.data(), static_cast<std::streamsize>(size)); |
| 94 | } |
| 95 | buffer.push_back('\0'); |
| 96 | return true; |
| 97 | } |
| 98 | |
| 99 | return false; |
| 100 | } |
| 101 | |
| 102 | // Read the contents of a stream into an array of char |
| 103 | bool getStreamContents(sf::InputStream& stream, std::vector<char>& buffer) |
no test coverage detected