| OLD | NEW |
| 1 // Copyright (c) 2011 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 "chrome/common/zip_reader.h" | 5 #include "chrome/common/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/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/common/zip_internal.h" | 11 #include "chrome/common/zip_internal.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 const int open_result = unzOpenCurrentFile(zip_file_); | 183 const int open_result = unzOpenCurrentFile(zip_file_); |
| 184 if (open_result != UNZ_OK) | 184 if (open_result != UNZ_OK) |
| 185 return false; | 185 return false; |
| 186 | 186 |
| 187 // We can't rely on parent directory entries being specified in the | 187 // We can't rely on parent directory entries being specified in the |
| 188 // zip, so we make sure they are created. | 188 // zip, so we make sure they are created. |
| 189 FilePath output_dir_path = output_file_path.DirName(); | 189 FilePath output_dir_path = output_file_path.DirName(); |
| 190 if (!file_util::CreateDirectory(output_dir_path)) | 190 if (!file_util::CreateDirectory(output_dir_path)) |
| 191 return false; | 191 return false; |
| 192 | 192 |
| 193 net::FileStream stream; | 193 net::FileStream stream(NULL); |
| 194 const int flags = (base::PLATFORM_FILE_CREATE_ALWAYS | | 194 const int flags = (base::PLATFORM_FILE_CREATE_ALWAYS | |
| 195 base::PLATFORM_FILE_WRITE); | 195 base::PLATFORM_FILE_WRITE); |
| 196 if (stream.Open(output_file_path, flags) != 0) | 196 if (stream.Open(output_file_path, flags) != 0) |
| 197 return false; | 197 return false; |
| 198 | 198 |
| 199 bool success = true; // This becomes false when something bad happens. | 199 bool success = true; // This becomes false when something bad happens. |
| 200 while (true) { | 200 while (true) { |
| 201 char buf[internal::kZipBufSize]; | 201 char buf[internal::kZipBufSize]; |
| 202 const int num_bytes_read = unzReadCurrentFile(zip_file_, buf, | 202 const int num_bytes_read = unzReadCurrentFile(zip_file_, buf, |
| 203 internal::kZipBufSize); | 203 internal::kZipBufSize); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 } | 289 } |
| 290 | 290 |
| 291 void ZipReader::Reset() { | 291 void ZipReader::Reset() { |
| 292 zip_file_ = NULL; | 292 zip_file_ = NULL; |
| 293 num_entries_ = 0; | 293 num_entries_ = 0; |
| 294 reached_end_ = false; | 294 reached_end_ = false; |
| 295 current_entry_info_.reset(); | 295 current_entry_info_.reset(); |
| 296 } | 296 } |
| 297 | 297 |
| 298 } // namespace zip | 298 } // namespace zip |
| OLD | NEW |