| 124 | |
| 125 | |
| 126 | long getSize(FILE* file) { |
| 127 | long original_offset = ftell(file); |
| 128 | |
| 129 | if (fseek(file, 0, SEEK_END) != 0) { |
| 130 | LOGGER.error("fseek failed"); |
| 131 | return -1; |
| 132 | } |
| 133 | |
| 134 | long file_size = ftell(file); |
| 135 | if (file_size == -1) { |
| 136 | LOGGER.error("Could not get file length"); |
| 137 | return -1; |
| 138 | } |
| 139 | |
| 140 | if (fseek(file, original_offset, SEEK_SET) != 0) { |
| 141 | LOGGER.error("fseek Failed"); |
| 142 | return -1; |
| 143 | } |
| 144 | |
| 145 | return file_size; |
| 146 | } |
| 147 | |
| 148 | /** Read a file. |
| 149 | * @param[in] filepath |
no test coverage detected