| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium 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 "third_party/zlib/google/zip_reader.h" | 5 #include "third_party/zlib/google/zip_reader.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 // zip files, so we construct the time as local time. | 159 // zip files, so we construct the time as local time. |
| 160 base::Time::Exploded exploded_time = {}; // Zero-clear. | 160 base::Time::Exploded exploded_time = {}; // Zero-clear. |
| 161 exploded_time.year = raw_file_info.tmu_date.tm_year; | 161 exploded_time.year = raw_file_info.tmu_date.tm_year; |
| 162 // The month in zip file is 0-based, whereas ours is 1-based. | 162 // The month in zip file is 0-based, whereas ours is 1-based. |
| 163 exploded_time.month = raw_file_info.tmu_date.tm_mon + 1; | 163 exploded_time.month = raw_file_info.tmu_date.tm_mon + 1; |
| 164 exploded_time.day_of_month = raw_file_info.tmu_date.tm_mday; | 164 exploded_time.day_of_month = raw_file_info.tmu_date.tm_mday; |
| 165 exploded_time.hour = raw_file_info.tmu_date.tm_hour; | 165 exploded_time.hour = raw_file_info.tmu_date.tm_hour; |
| 166 exploded_time.minute = raw_file_info.tmu_date.tm_min; | 166 exploded_time.minute = raw_file_info.tmu_date.tm_min; |
| 167 exploded_time.second = raw_file_info.tmu_date.tm_sec; | 167 exploded_time.second = raw_file_info.tmu_date.tm_sec; |
| 168 exploded_time.millisecond = 0; | 168 exploded_time.millisecond = 0; |
| 169 if (exploded_time.HasValidValues()) { | 169 |
| 170 last_modified_ = base::Time::FromLocalExploded(exploded_time); | 170 if (!base::Time::FromLocalExploded(exploded_time, &last_modified_)) |
| 171 } else { | |
| 172 // Use Unix time epoch if the time stamp data is invalid. | |
| 173 last_modified_ = base::Time::UnixEpoch(); | 171 last_modified_ = base::Time::UnixEpoch(); |
| 174 } | |
| 175 } | 172 } |
| 176 | 173 |
| 177 ZipReader::ZipReader() | 174 ZipReader::ZipReader() |
| 178 : weak_ptr_factory_(this) { | 175 : weak_ptr_factory_(this) { |
| 179 Reset(); | 176 Reset(); |
| 180 } | 177 } |
| 181 | 178 |
| 182 ZipReader::~ZipReader() { | 179 ZipReader::~ZipReader() { |
| 183 Close(); | 180 Close(); |
| 184 } | 181 } |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 } | 526 } |
| 530 | 527 |
| 531 bool FileWriterDelegate::WriteBytes(const char* data, int num_bytes) { | 528 bool FileWriterDelegate::WriteBytes(const char* data, int num_bytes) { |
| 532 int bytes_written = file_->WriteAtCurrentPos(data, num_bytes); | 529 int bytes_written = file_->WriteAtCurrentPos(data, num_bytes); |
| 533 if (bytes_written > 0) | 530 if (bytes_written > 0) |
| 534 file_length_ += bytes_written; | 531 file_length_ += bytes_written; |
| 535 return bytes_written == num_bytes; | 532 return bytes_written == num_bytes; |
| 536 } | 533 } |
| 537 | 534 |
| 538 } // namespace zip | 535 } // namespace zip |
| OLD | NEW |