| 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 "third_party/zlib/google/zip.h" | 5 #include "third_party/zlib/google/zip.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 return true; | 49 return true; |
| 50 } | 50 } |
| 51 | 51 |
| 52 bool AddEntryToZip(zipFile zip_file, const base::FilePath& path, | 52 bool AddEntryToZip(zipFile zip_file, const base::FilePath& path, |
| 53 const base::FilePath& root_path) { | 53 const base::FilePath& root_path) { |
| 54 base::FilePath relative_path; | 54 base::FilePath relative_path; |
| 55 bool result = root_path.AppendRelativePath(path, &relative_path); | 55 bool result = root_path.AppendRelativePath(path, &relative_path); |
| 56 DCHECK(result); | 56 DCHECK(result); |
| 57 std::string str_path = relative_path.AsUTF8Unsafe(); | 57 std::string str_path = relative_path.AsUTF8Unsafe(); |
| 58 #if defined(OS_WIN) | 58 #if defined(OS_WIN) |
| 59 ReplaceSubstringsAfterOffset(&str_path, 0u, "\\", "/"); | 59 base::ReplaceSubstringsAfterOffset(&str_path, 0u, "\\", "/"); |
| 60 #endif | 60 #endif |
| 61 | 61 |
| 62 bool is_directory = base::DirectoryExists(path); | 62 bool is_directory = base::DirectoryExists(path); |
| 63 if (is_directory) | 63 if (is_directory) |
| 64 str_path += "/"; | 64 str_path += "/"; |
| 65 | 65 |
| 66 zip_fileinfo file_info = zip::internal::GetFileInfoForZipping(path); | 66 zip_fileinfo file_info = zip::internal::GetFileInfoForZipping(path); |
| 67 if (!zip::internal::ZipOpenNewFileInZip(zip_file, str_path, &file_info)) | 67 if (!zip::internal::ZipOpenNewFileInZip(zip_file, str_path, &file_info)) |
| 68 return false; | 68 return false; |
| 69 | 69 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 if (ZIP_OK != zipClose(zip_file, NULL)) { | 195 if (ZIP_OK != zipClose(zip_file, NULL)) { |
| 196 DLOG(ERROR) << "Error closing zip file for fd " << dest_fd; | 196 DLOG(ERROR) << "Error closing zip file for fd " << dest_fd; |
| 197 success = false; | 197 success = false; |
| 198 } | 198 } |
| 199 | 199 |
| 200 return success; | 200 return success; |
| 201 } | 201 } |
| 202 #endif // defined(OS_POSIX) | 202 #endif // defined(OS_POSIX) |
| 203 | 203 |
| 204 } // namespace zip | 204 } // namespace zip |
| OLD | NEW |