implement patch serving
This commit is contained in:
@@ -445,6 +445,28 @@ void send_enter_directory_patch(shared_ptr<Client> c, const string& dir) {
|
||||
send_command_t(c, 0x09, 0x00, cmd);
|
||||
}
|
||||
|
||||
void send_patch_file(shared_ptr<Client> c, shared_ptr<const PatchFileIndex::File> f) {
|
||||
S_OpenFile_Patch_06 open_cmd = {0, f->size, f->name};
|
||||
send_command_t(c, 0x06, 0x00, open_cmd);
|
||||
|
||||
for (size_t x = 0; x < f->chunks.size(); x++) {
|
||||
const auto& chunk = f->chunks[x];
|
||||
|
||||
// TODO: The use of StringWriter here is... unfortunate. Write a version of
|
||||
// Channel::send that takes iovecs or something to avoid these dumb massive
|
||||
// string copies.
|
||||
StringWriter w;
|
||||
S_WriteFileHeader_Patch_07 write_cmd_header = {
|
||||
x, chunk.crc32, chunk.data.size()};
|
||||
w.put(write_cmd_header);
|
||||
w.write(chunk.data);
|
||||
send_command(c, 0x07, 0x00, w.str());
|
||||
}
|
||||
|
||||
S_CloseCurrentFile_Patch_08 close_cmd = {0};
|
||||
send_command_t(c, 0x08, 0x00, close_cmd);
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user