| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "update_engine/delta_performer.h" | 5 #include "update_engine/delta_performer.h" |
| 6 #include <endian.h> | 6 #include <endian.h> |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <cstring> | 9 #include <cstring> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 return -errno; | 103 return -errno; |
| 104 fd_ = -2; // Set so that isn't not valid AND calls to Open() will fail. | 104 fd_ = -2; // Set so that isn't not valid AND calls to Open() will fail. |
| 105 path_ = ""; | 105 path_ = ""; |
| 106 return 0; | 106 return 0; |
| 107 } | 107 } |
| 108 | 108 |
| 109 // Wrapper around write. Returns bytes written on success or | 109 // Wrapper around write. Returns bytes written on success or |
| 110 // -errno on error. | 110 // -errno on error. |
| 111 // This function performs as many actions as it can, given the amount of | 111 // This function performs as many actions as it can, given the amount of |
| 112 // data received thus far. | 112 // data received thus far. |
| 113 int DeltaPerformer::Write(const void* bytes, size_t count) { | 113 ssize_t DeltaPerformer::Write(const void* bytes, size_t count) { |
| 114 const char* c_bytes = reinterpret_cast<const char*>(bytes); | 114 const char* c_bytes = reinterpret_cast<const char*>(bytes); |
| 115 buffer_.insert(buffer_.end(), c_bytes, c_bytes + count); | 115 buffer_.insert(buffer_.end(), c_bytes, c_bytes + count); |
| 116 | 116 |
| 117 if (!manifest_valid_) { | 117 if (!manifest_valid_) { |
| 118 // See if we have enough bytes for the manifest yet | 118 // See if we have enough bytes for the manifest yet |
| 119 if (buffer_.size() < strlen(kDeltaMagic) + | 119 if (buffer_.size() < strlen(kDeltaMagic) + |
| 120 kDeltaVersionLength + kDeltaProtobufLengthLength) { | 120 kDeltaVersionLength + kDeltaProtobufLengthLength) { |
| 121 // Don't have enough bytes to even know the protobuf length | 121 // Don't have enough bytes to even know the protobuf length |
| 122 return count; | 122 return count; |
| 123 } | 123 } |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 utils::PWriteAll(fd_, &zeros[0], end_byte - begin_byte, begin_byte)); | 367 utils::PWriteAll(fd_, &zeros[0], end_byte - begin_byte, begin_byte)); |
| 368 } | 368 } |
| 369 | 369 |
| 370 // Update buffer. | 370 // Update buffer. |
| 371 buffer_offset_ += operation.data_length(); | 371 buffer_offset_ += operation.data_length(); |
| 372 RemoveBufferHeadBytes(&buffer_, operation.data_length()); | 372 RemoveBufferHeadBytes(&buffer_, operation.data_length()); |
| 373 return true; | 373 return true; |
| 374 } | 374 } |
| 375 | 375 |
| 376 } // namespace chromeos_update_engine | 376 } // namespace chromeos_update_engine |
| OLD | NEW |