| 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 "chrome/common/zip.h" | 5 #include "chrome/common/zip.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "chrome/common/zip_internal.h" | 12 #include "chrome/common/zip_internal.h" |
| 13 #include "chrome/common/zip_reader.h" | 13 #include "chrome/common/zip_reader.h" |
| 14 #include "net/base/file_stream.h" | 14 #include "net/base/file_stream.h" |
| 15 #include "third_party/zlib/contrib/minizip/unzip.h" | 15 #include "third_party/zlib/contrib/minizip/unzip.h" |
| 16 #include "third_party/zlib/contrib/minizip/zip.h" | 16 #include "third_party/zlib/contrib/minizip/zip.h" |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 bool AddFileToZip(zipFile zip_file, const FilePath& src_dir) { | 20 bool AddFileToZip(zipFile zip_file, const FilePath& src_dir) { |
| 21 net::FileStream stream(NULL); | 21 net::FileStream stream(NULL); |
| 22 int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; | 22 int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; |
| 23 if (stream.Open(src_dir, flags) != 0) { | 23 if (stream.OpenSync(src_dir, flags) != 0) { |
| 24 DLOG(ERROR) << "Could not open stream for path " | 24 DLOG(ERROR) << "Could not open stream for path " |
| 25 << src_dir.value(); | 25 << src_dir.value(); |
| 26 return false; | 26 return false; |
| 27 } | 27 } |
| 28 | 28 |
| 29 int num_bytes; | 29 int num_bytes; |
| 30 char buf[zip::internal::kZipBufSize]; | 30 char buf[zip::internal::kZipBufSize]; |
| 31 do { | 31 do { |
| 32 num_bytes = stream.Read(buf, zip::internal::kZipBufSize, | 32 num_bytes = stream.Read(buf, zip::internal::kZipBufSize, |
| 33 net::CompletionCallback()); | 33 net::CompletionCallback()); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 if (include_hidden_files) { | 161 if (include_hidden_files) { |
| 162 return ZipWithFilterCallback( | 162 return ZipWithFilterCallback( |
| 163 src_dir, dest_file, base::Bind(&ExcludeNoFilesFilter)); | 163 src_dir, dest_file, base::Bind(&ExcludeNoFilesFilter)); |
| 164 } else { | 164 } else { |
| 165 return ZipWithFilterCallback( | 165 return ZipWithFilterCallback( |
| 166 src_dir, dest_file, base::Bind(&ExcludeHiddenFilesFilter)); | 166 src_dir, dest_file, base::Bind(&ExcludeHiddenFilesFilter)); |
| 167 } | 167 } |
| 168 } | 168 } |
| 169 | 169 |
| 170 } // namespace zip | 170 } // namespace zip |
| OLD | NEW |