| 164 | } |
| 165 | |
| 166 | void writeToFile(const std::string &filename, const std::string &content) { |
| 167 | FILE *f = fopen(filename.c_str(), "wb"); |
| 168 | if (!f || (content.size() && fwrite(content.c_str(), content.size(), 1, f) != 1)) { |
| 169 | LOG_S(ERROR) << "failed to write to " << filename << ' ' << strerror(errno); |
| 170 | return; |
| 171 | } |
| 172 | fclose(f); |
| 173 | } |
| 174 | |
| 175 | // Find discontinous |search| in |content|. |
| 176 | // Return |found| and the count of skipped chars before found. |