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 |
| 16 #if defined(USE_SYSTEM_MINIZIP) |
| 17 #include <minizip/unzip.h> |
| 18 #include <minizip/zip.h> |
| 19 #else |
15 #include "third_party/zlib/contrib/minizip/unzip.h" | 20 #include "third_party/zlib/contrib/minizip/unzip.h" |
16 #include "third_party/zlib/contrib/minizip/zip.h" | 21 #include "third_party/zlib/contrib/minizip/zip.h" |
| 22 #endif |
17 | 23 |
18 namespace { | 24 namespace { |
19 | 25 |
20 bool AddFileToZip(zipFile zip_file, const FilePath& src_dir) { | 26 bool AddFileToZip(zipFile zip_file, const FilePath& src_dir) { |
21 net::FileStream stream(NULL); | 27 net::FileStream stream(NULL); |
22 int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; | 28 int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; |
23 if (stream.OpenSync(src_dir, flags) != 0) { | 29 if (stream.OpenSync(src_dir, flags) != 0) { |
24 DLOG(ERROR) << "Could not open stream for path " | 30 DLOG(ERROR) << "Could not open stream for path " |
25 << src_dir.value(); | 31 << src_dir.value(); |
26 return false; | 32 return false; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 if (include_hidden_files) { | 164 if (include_hidden_files) { |
159 return ZipWithFilterCallback( | 165 return ZipWithFilterCallback( |
160 src_dir, dest_file, base::Bind(&ExcludeNoFilesFilter)); | 166 src_dir, dest_file, base::Bind(&ExcludeNoFilesFilter)); |
161 } else { | 167 } else { |
162 return ZipWithFilterCallback( | 168 return ZipWithFilterCallback( |
163 src_dir, dest_file, base::Bind(&ExcludeHiddenFilesFilter)); | 169 src_dir, dest_file, base::Bind(&ExcludeHiddenFilesFilter)); |
164 } | 170 } |
165 } | 171 } |
166 | 172 |
167 } // namespace zip | 173 } // namespace zip |
OLD | NEW |