| 14 | #include <string> |
| 15 | |
| 16 | char* textFileRead(const char *fn) |
| 17 | { |
| 18 | FILE *file; |
| 19 | char *content = NULL; |
| 20 | |
| 21 | int count = 0; |
| 22 | |
| 23 | if (fn != NULL) |
| 24 | { |
| 25 | const std::string resolvedPath = resolveResourcePath(fn); |
| 26 | file = fopen(resolvedPath.c_str(), "rt"); |
| 27 | |
| 28 | if (file != NULL) |
| 29 | { |
| 30 | fseek(file, 0, SEEK_END); |
| 31 | count = ftell(file); |
| 32 | rewind(file); |
| 33 | |
| 34 | if (count > 0) |
| 35 | { |
| 36 | content = (char *)malloc(sizeof(char) * (count + 1)); |
| 37 | count = static_cast<int>(fread(content, sizeof(char), count, file)); |
| 38 | content[count] = '\0'; |
| 39 | } |
| 40 | fclose(file); |
| 41 | } |
| 42 | } |
| 43 | return content; |
| 44 | } |
| 45 | |
| 46 | int textFileWrite(const char *fn, const char *s) |
| 47 | { |
no test coverage detected