Chromium Code Reviews| Index: third_party/zlib/google/zip.cc |
| diff --git a/third_party/zlib/google/zip.cc b/third_party/zlib/google/zip.cc |
| index 52fc6948bb6aa38a68c5dec74284786d3faca707..5508ab9831f31db874a130e79e5085f9c10f2a55 100644 |
| --- a/third_party/zlib/google/zip.cc |
| +++ b/third_party/zlib/google/zip.cc |
| @@ -27,38 +27,6 @@ |
| namespace { |
| -// Returns a zip_fileinfo struct with the time represented by |file_time|. |
| -zip_fileinfo TimeToZipFileInfo(const base::Time& file_time) { |
| - base::Time::Exploded file_time_parts; |
| - file_time.LocalExplode(&file_time_parts); |
| - |
| - zip_fileinfo zip_info = {}; |
| - if (file_time_parts.year >= 1980) { |
| - // This if check works around the handling of the year value in |
| - // contrib/minizip/zip.c in function zip64local_TmzDateToDosDate |
| - // It assumes that dates below 1980 are in the double digit format. |
| - // Hence the fail safe option is to leave the date unset. Some programs |
| - // might show the unset date as 1980-0-0 which is invalid. |
| - zip_info.tmz_date.tm_year = file_time_parts.year; |
| - zip_info.tmz_date.tm_mon = file_time_parts.month - 1; |
| - zip_info.tmz_date.tm_mday = file_time_parts.day_of_month; |
| - zip_info.tmz_date.tm_hour = file_time_parts.hour; |
| - zip_info.tmz_date.tm_min = file_time_parts.minute; |
| - zip_info.tmz_date.tm_sec = file_time_parts.second; |
| - } |
| - |
| - return zip_info; |
| -} |
| - |
| -// Returns a zip_fileinfo with the last modification date of |path| set. |
| -zip_fileinfo GetFileInfoForZipping(const base::FilePath& path) { |
| - base::Time file_time; |
| - base::File::Info file_info; |
| - if (base::GetFileInfo(path, &file_info)) |
| - file_time = file_info.last_modified; |
| - return TimeToZipFileInfo(file_time); |
| -} |
| - |
| bool AddFileToZip(zipFile zip_file, const base::FilePath& src_dir) { |
| net::FileStream stream(NULL); |
| int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; |
| @@ -98,34 +66,10 @@ bool AddEntryToZip(zipFile zip_file, const base::FilePath& path, |
| if (is_directory) |
| str_path += "/"; |
| - // Section 4.4.4 http://www.pkware.com/documents/casestudies/APPNOTE.TXT |
| - // Setting the Language encoding flag so the file is told to be in utf-8. |
| - const uLong LANGUAGE_ENCODING_FLAG = 0x1 << 11; |
| - |
| - zip_fileinfo file_info = GetFileInfoForZipping(path); |
| - |
| - if (ZIP_OK != zipOpenNewFileInZip4( |
| - zip_file, // file |
| - str_path.c_str(), // filename |
| - &file_info, // zipfi |
| - NULL, // extrafield_local, |
| - 0u, // size_extrafield_local |
| - NULL, // extrafield_global |
| - 0u, // size_extrafield_global |
| - NULL, // comment |
| - Z_DEFLATED, // method |
| - Z_DEFAULT_COMPRESSION, // level |
| - 0, // raw |
| - -MAX_WBITS, // windowBits |
| - DEF_MEM_LEVEL, // memLevel |
| - Z_DEFAULT_STRATEGY, // strategy |
| - NULL, // password |
| - 0, // crcForCrypting |
| - 0, // versionMadeBy |
| - LANGUAGE_ENCODING_FLAG)) { // flagBase |
| - DLOG(ERROR) << "Could not open zip file entry " << str_path; |
| + zip_fileinfo file_info = zip::internal::GetFileInfoForZipping(path); |
| + if (!zip::internal::ZipOpenNewFileInZipWrapper( |
| + zip_file, str_path, &file_info)) |
| return false; |
| - } |
| bool success = true; |
| if (!is_directory) { |
| @@ -197,7 +141,8 @@ bool ZipWithFilterCallback(const base::FilePath& src_dir, |
| bool success = true; |
| base::FileEnumerator file_enumerator(src_dir, true /* recursive */, |
| base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES); |
| - for (base::FilePath path = file_enumerator.Next(); !path.value().empty(); |
| + for (base::FilePath path = file_enumerator.Next(); |
| + !path.value().empty() && success; |
| path = file_enumerator.Next()) { |
| if (!filter_cb.Run(path)) { |
| continue; |
| @@ -205,7 +150,6 @@ bool ZipWithFilterCallback(const base::FilePath& src_dir, |
| if (!AddEntryToZip(zip_file, path, src_dir)) { |
| success = false; |
| - return false; |
| } |
| } |
| @@ -243,7 +187,7 @@ bool ZipFiles(const base::FilePath& src_dir, |
| bool success = true; |
| for (std::vector<base::FilePath>::const_iterator iter = |
| src_relative_paths.begin(); |
| - iter != src_relative_paths.end(); ++iter) { |
| + iter != src_relative_paths.end() && success; ++iter) { |
|
hshi1
2014/03/19 17:33:27
the "&& success" part is redundant because the "br
|
| const base::FilePath& path = src_dir.Append(*iter); |
| if (!AddEntryToZip(zip_file, path, src_dir)) { |
| // TODO(hshi): clean up the partial zip file when error occurs. |