| 41 | } |
| 42 | |
| 43 | void loadKernelCode(const std::string &filename, std::string &codeString) { |
| 44 | codeString = ""; |
| 45 | FILE *file = fopen(filename.c_str(), "r"); |
| 46 | int nTries = 0; |
| 47 | while (!file) { |
| 48 | fclose(file); |
| 49 | std::this_thread::sleep_for(std::chrono::milliseconds(10)); |
| 50 | file = fopen(filename.c_str(), "r"); |
| 51 | if (++nTries > 5) { |
| 52 | LOG(kDefLog, kError, "Failed to open file: %s", filename.c_str()); |
| 53 | return; |
| 54 | } |
| 55 | } |
| 56 | char buffer[4096]; |
| 57 | while (fgets(buffer, sizeof(buffer), file)) { |
| 58 | codeString += buffer; |
| 59 | } |
| 60 | fclose(file); |
| 61 | } |
| 62 | |
| 63 | int main() { |
| 64 | |