Add the file and calculate the md5 sum. */
| 152 | |
| 153 | /* Add the file and calculate the md5 sum. */ |
| 154 | bool AddFile(const std::string &filename, size_t, const std::string &) override |
| 155 | { |
| 156 | Md5 checksum; |
| 157 | uint8_t buffer[1024]; |
| 158 | size_t len, size; |
| 159 | |
| 160 | /* Open the file ... */ |
| 161 | auto f = FioFOpenFile(filename, "rb", this->dir, &size); |
| 162 | if (!f.has_value()) return false; |
| 163 | |
| 164 | /* ... calculate md5sum... */ |
| 165 | while ((len = fread(buffer, 1, (size > sizeof(buffer)) ? sizeof(buffer) : size, *f)) != 0 && size != 0) { |
| 166 | size -= len; |
| 167 | checksum.Append(buffer, len); |
| 168 | } |
| 169 | |
| 170 | MD5Hash tmp_md5sum; |
| 171 | checksum.Finish(tmp_md5sum); |
| 172 | |
| 173 | /* ... and xor it to the overall md5sum. */ |
| 174 | this->md5sum ^= tmp_md5sum; |
| 175 | |
| 176 | return true; |
| 177 | } |
| 178 | }; |
| 179 | |
| 180 | /** |
nothing calls this directly
no test coverage detected