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 "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 break; | 224 break; |
225 } else if (num_bytes_read > 0) { | 225 } else if (num_bytes_read > 0) { |
226 // Some data is read. Write it to the output file. | 226 // Some data is read. Write it to the output file. |
227 if (num_bytes_read != stream.WriteSync(buf, num_bytes_read)) { | 227 if (num_bytes_read != stream.WriteSync(buf, num_bytes_read)) { |
228 success = false; | 228 success = false; |
229 break; | 229 break; |
230 } | 230 } |
231 } | 231 } |
232 } | 232 } |
233 | 233 |
| 234 stream.CloseSync(); |
234 unzCloseCurrentFile(zip_file_); | 235 unzCloseCurrentFile(zip_file_); |
| 236 |
| 237 if (current_entry_info()->last_modified() != base::Time::UnixEpoch()) |
| 238 base::TouchFile(output_file_path, |
| 239 base::Time::Now(), |
| 240 current_entry_info()->last_modified()); |
| 241 |
235 return success; | 242 return success; |
236 } | 243 } |
237 | 244 |
238 bool ZipReader::ExtractCurrentEntryIntoDirectory( | 245 bool ZipReader::ExtractCurrentEntryIntoDirectory( |
239 const base::FilePath& output_directory_path) { | 246 const base::FilePath& output_directory_path) { |
240 DCHECK(current_entry_info_.get()); | 247 DCHECK(current_entry_info_.get()); |
241 | 248 |
242 base::FilePath output_file_path = output_directory_path.Append( | 249 base::FilePath output_file_path = output_directory_path.Append( |
243 current_entry_info()->file_path()); | 250 current_entry_info()->file_path()); |
244 return ExtractCurrentEntryToFilePath(output_file_path); | 251 return ExtractCurrentEntryToFilePath(output_file_path); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 } | 308 } |
302 | 309 |
303 void ZipReader::Reset() { | 310 void ZipReader::Reset() { |
304 zip_file_ = NULL; | 311 zip_file_ = NULL; |
305 num_entries_ = 0; | 312 num_entries_ = 0; |
306 reached_end_ = false; | 313 reached_end_ = false; |
307 current_entry_info_.reset(); | 314 current_entry_info_.reset(); |
308 } | 315 } |
309 | 316 |
310 } // namespace zip | 317 } // namespace zip |
OLD | NEW |