Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: src/platform/update_engine/split_file_writer.cc

Issue 1694025: AU: Update Downloader to support our image formats. (Closed) Base URL: ssh://git@chromiumos-git/chromeos
Patch Set: fixes for review Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/platform/update_engine/install_plan.h ('k') | src/platform/update_engine/test_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/split_file_writer.h" 5 #include "update_engine/split_file_writer.h"
6 #include <algorithm> 6 #include <algorithm>
7 7
8 using std::min; 8 using std::min;
9 9
10 namespace chromeos_update_engine { 10 namespace chromeos_update_engine {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 } 42 }
43 43
44 ssize_t SplitFileWriter::Write(const void* bytes, size_t count) { 44 ssize_t SplitFileWriter::Write(const void* bytes, size_t count) {
45 const size_t original_count = count; 45 const size_t original_count = count;
46 46
47 // This first block is trying to read the first sizeof(uint64_t) 47 // This first block is trying to read the first sizeof(uint64_t)
48 // bytes, which are the number of bytes that should be written 48 // bytes, which are the number of bytes that should be written
49 // to the first FileWriter. 49 // to the first FileWriter.
50 if (bytes_received_ < static_cast<off_t>(sizeof(uint64_t))) { 50 if (bytes_received_ < static_cast<off_t>(sizeof(uint64_t))) {
51 // Write more to the initial buffer 51 // Write more to the initial buffer
52 size_t bytes_to_copy = min(count, 52 size_t bytes_to_copy = min(static_cast<off_t>(count),
53 sizeof(first_length_buf_) - bytes_received_); 53 static_cast<off_t>(sizeof(first_length_buf_)) -
54 bytes_received_);
54 memcpy(&first_length_buf_[bytes_received_], bytes, bytes_to_copy); 55 memcpy(&first_length_buf_[bytes_received_], bytes, bytes_to_copy);
55 bytes_received_ += bytes_to_copy; 56 bytes_received_ += bytes_to_copy;
56 count -= bytes_to_copy; 57 count -= bytes_to_copy;
57 bytes = static_cast<const void*>( 58 bytes = static_cast<const void*>(
58 static_cast<const char*>(bytes) + bytes_to_copy); 59 static_cast<const char*>(bytes) + bytes_to_copy);
59 60
60 // See if we have all we need 61 // See if we have all we need
61 if (bytes_received_ == sizeof(first_length_buf_)) { 62 if (bytes_received_ == sizeof(first_length_buf_)) {
62 // Parse first number 63 // Parse first number
63 uint64_t big_endian_first_length; 64 uint64_t big_endian_first_length;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 if (first_result < 0) 105 if (first_result < 0)
105 LOG(ERROR) << "Error Close()ing first file."; 106 LOG(ERROR) << "Error Close()ing first file.";
106 int second_result = second_file_writer_->Close(); 107 int second_result = second_file_writer_->Close();
107 if (second_result < 0) 108 if (second_result < 0)
108 LOG(ERROR) << "Error Close()ing second file."; 109 LOG(ERROR) << "Error Close()ing second file.";
109 // Return error if either had returned error. 110 // Return error if either had returned error.
110 return second_result < 0 ? second_result : first_result; 111 return second_result < 0 ? second_result : first_result;
111 } 112 }
112 113
113 } // namespace chromeos_update_engine 114 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « src/platform/update_engine/install_plan.h ('k') | src/platform/update_engine/test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698