MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / HandleFile

Method HandleFile

extensions/updater/Updater.cpp:205–242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203}
204
205void UpdateReader::HandleFile()
206{
207 MD5 md5;
208 char real_checksum[33];
209
210 mdl.Reset();
211
212 if (!xfer->Download(url.c_str(), &mdl, NULL))
213 {
214 AddUpdateError("Could not download \"%s\"", url.c_str());
215 AddUpdateError("Error: %s", xfer->LastErrorMessage());
216 return;
217 }
218
219 md5.update((unsigned char *)mdl.GetBuffer(), mdl.GetSize());
220 md5.finalize();
221 md5.hex_digest(real_checksum);
222
223 if (mdl.GetSize() == 0)
224 {
225 AddUpdateError("Zero-length file returned for \"%s\"", curfile.c_str());
226 return;
227 }
228
229 if (strcasecmp(checksum, real_checksum) != 0)
230 {
231 AddUpdateError("Checksums for file \"%s\" do not match:", curfile.c_str());
232 AddUpdateError("Expected: %s Real: %s", checksum, real_checksum);
233 return;
234 }
235
236 UpdatePart *part = new UpdatePart;
237 part->data = (char*)malloc(mdl.GetSize());
238 memcpy(part->data, mdl.GetBuffer(), mdl.GetSize());
239 part->file = strdup(curfile.c_str());
240 part->length = mdl.GetSize();
241 LinkPart(part);
242}
243
244void UpdateReader::HandleFolder(const char *folder)
245{

Callers

nothing calls this directly

Calls 10

AddUpdateErrorFunction · 0.85
DownloadMethod · 0.80
LastErrorMessageMethod · 0.80
GetBufferMethod · 0.80
GetSizeMethod · 0.80
ResetMethod · 0.45
c_strMethod · 0.45
updateMethod · 0.45
finalizeMethod · 0.45
hex_digestMethod · 0.45

Tested by

no test coverage detected