OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/string_split.h" | 9 #include "base/string_split.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 #endif | 284 #endif |
285 | 285 |
286 if (!zip_file) { | 286 if (!zip_file) { |
287 LOG(WARNING) << "couldn't create file " << dest_file_str; | 287 LOG(WARNING) << "couldn't create file " << dest_file_str; |
288 return false; | 288 return false; |
289 } | 289 } |
290 | 290 |
291 bool success = true; | 291 bool success = true; |
292 file_util::FileEnumerator file_enumerator( | 292 file_util::FileEnumerator file_enumerator( |
293 src_dir, true, // recursive | 293 src_dir, true, // recursive |
294 static_cast<file_util::FileEnumerator::FILE_TYPE>( | 294 static_cast<file_util::FileEnumerator::FileType>( |
295 file_util::FileEnumerator::FILES | | 295 file_util::FileEnumerator::FILES | |
296 file_util::FileEnumerator::DIRECTORIES)); | 296 file_util::FileEnumerator::DIRECTORIES)); |
297 for (FilePath path = file_enumerator.Next(); !path.value().empty(); | 297 for (FilePath path = file_enumerator.Next(); !path.value().empty(); |
298 path = file_enumerator.Next()) { | 298 path = file_enumerator.Next()) { |
299 if (!include_hidden_files && path.BaseName().value()[0] == '.') | 299 if (!include_hidden_files && path.BaseName().value()[0] == '.') |
300 continue; | 300 continue; |
301 | 301 |
302 if (!AddEntryToZip(zip_file, path, src_dir)) { | 302 if (!AddEntryToZip(zip_file, path, src_dir)) { |
303 success = false; | 303 success = false; |
304 return false; | 304 return false; |
305 } | 305 } |
306 } | 306 } |
307 | 307 |
308 if (ZIP_OK != zipClose(zip_file, NULL)) { // global comment | 308 if (ZIP_OK != zipClose(zip_file, NULL)) { // global comment |
309 LOG(ERROR) << "Error closing zip file " << dest_file_str; | 309 LOG(ERROR) << "Error closing zip file " << dest_file_str; |
310 return false; | 310 return false; |
311 } | 311 } |
312 | 312 |
313 return success; | 313 return success; |
314 } | 314 } |
OLD | NEW |