| 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" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 123 |
| 124 zipFile zip_file = internal::OpenForZipping(dest_file.AsUTF8Unsafe(), | 124 zipFile zip_file = internal::OpenForZipping(dest_file.AsUTF8Unsafe(), |
| 125 APPEND_STATUS_CREATE); | 125 APPEND_STATUS_CREATE); |
| 126 | 126 |
| 127 if (!zip_file) { | 127 if (!zip_file) { |
| 128 DLOG(WARNING) << "couldn't create file " << dest_file.value(); | 128 DLOG(WARNING) << "couldn't create file " << dest_file.value(); |
| 129 return false; | 129 return false; |
| 130 } | 130 } |
| 131 | 131 |
| 132 bool success = true; | 132 bool success = true; |
| 133 file_util::FileEnumerator file_enumerator( | 133 file_util::FileEnumerator file_enumerator(src_dir, true /* recursive */, |
| 134 src_dir, true, // recursive | 134 (file_util::FileEnumerator::FILES | |
| 135 static_cast<file_util::FileEnumerator::FileType>( | 135 file_util::FileEnumerator::DIRECTORIES)); |
| 136 file_util::FileEnumerator::FILES | | |
| 137 file_util::FileEnumerator::DIRECTORIES)); | |
| 138 for (FilePath path = file_enumerator.Next(); !path.value().empty(); | 136 for (FilePath path = file_enumerator.Next(); !path.value().empty(); |
| 139 path = file_enumerator.Next()) { | 137 path = file_enumerator.Next()) { |
| 140 if (!filter_cb.Run(path)) { | 138 if (!filter_cb.Run(path)) { |
| 141 continue; | 139 continue; |
| 142 } | 140 } |
| 143 | 141 |
| 144 if (!AddEntryToZip(zip_file, path, src_dir)) { | 142 if (!AddEntryToZip(zip_file, path, src_dir)) { |
| 145 success = false; | 143 success = false; |
| 146 return false; | 144 return false; |
| 147 } | 145 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 160 if (include_hidden_files) { | 158 if (include_hidden_files) { |
| 161 return ZipWithFilterCallback( | 159 return ZipWithFilterCallback( |
| 162 src_dir, dest_file, base::Bind(&ExcludeNoFilesFilter)); | 160 src_dir, dest_file, base::Bind(&ExcludeNoFilesFilter)); |
| 163 } else { | 161 } else { |
| 164 return ZipWithFilterCallback( | 162 return ZipWithFilterCallback( |
| 165 src_dir, dest_file, base::Bind(&ExcludeHiddenFilesFilter)); | 163 src_dir, dest_file, base::Bind(&ExcludeHiddenFilesFilter)); |
| 166 } | 164 } |
| 167 } | 165 } |
| 168 | 166 |
| 169 } // namespace zip | 167 } // namespace zip |
| OLD | NEW |