| 138 | } |
| 139 | |
| 140 | static bool write_bytes(const std::filesystem::path &path, const unsigned char *data, int size) { |
| 141 | std::error_code ec; |
| 142 | std::filesystem::create_directories(path.parent_path(), ec); |
| 143 | if (ec) { |
| 144 | LOGE("CSS stage assets: mkdirs failed for %s: %s", |
| 145 | path.parent_path().string().c_str(), ec.message().c_str()); |
| 146 | return false; |
| 147 | } |
| 148 | |
| 149 | std::ofstream f(path, std::ios::binary | std::ios::trunc); |
| 150 | if (!f) { |
| 151 | return false; |
| 152 | } |
| 153 | f.write(reinterpret_cast<const char *>(data), size); |
| 154 | return (bool)f; |
| 155 | } |
| 156 | |
| 157 | static bool extract_reloc_file(const std::vector<uint8_t> &rom, uint32_t file_id, |
| 158 | std::vector<uint8_t> &out) { |