Index: chrome/common/zip.cc |
diff --git a/chrome/common/zip.cc b/chrome/common/zip.cc |
index 9ec489459cd320345633eae4d9d4fe13b8a12439..93a896f463f5fb96750dc22d7e19fabef42db073 100644 |
--- a/chrome/common/zip.cc |
+++ b/chrome/common/zip.cc |
@@ -170,4 +170,38 @@ bool Zip(const FilePath& src_dir, const FilePath& dest_file, |
} |
} |
+bool ZipFileList(const FilePath& src_dir, const FilePath& dest_file, |
+ const std::vector<FilePath>& src_file_list) { |
+ DCHECK(file_util::DirectoryExists(src_dir)); |
+ |
+ zipFile zip_file = internal::OpenForZipping(dest_file.AsUTF8Unsafe(), |
+ APPEND_STATUS_CREATE); |
+ |
+ if (!zip_file) { |
+ DLOG(WARNING) << "couldn't create file " << dest_file.value(); |
+ return false; |
+ } |
+ |
+ bool success = true; |
+ for (std::vector<FilePath>::const_iterator iter = src_file_list.begin(); |
+ iter != src_file_list.end(); iter++) { |
+ const FilePath& path = *iter; |
+ if (!src_dir.IsParent(path)) { |
+ DLOG(ERROR) << "Ignoring file outside source directory " << path.value(); |
+ continue; |
+ } |
+ if (!AddEntryToZip(zip_file, path, src_dir)) { |
+ success = false; |
+ break; |
+ } |
+ } |
+ |
+ if (ZIP_OK != zipClose(zip_file, NULL)) { // global comment |
+ DLOG(ERROR) << "Error closing zip file " << dest_file.value(); |
+ success = false; |
+ } |
+ |
+ return success; |
+} |
+ |
} // namespace zip |