| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/file_enumerator.h" | 9 #include "base/files/file_enumerator.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 } while (num_bytes > 0); | 47 } while (num_bytes > 0); |
| 48 | 48 |
| 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 std::string str_path = | 54 std::string str_path = |
| 55 path.AsUTF8Unsafe().substr(root_path.value().length() + 1); | 55 path.AsUTF8Unsafe().substr(root_path.AsUTF8Unsafe().length() + 1); |
| 56 #if defined(OS_WIN) | 56 #if defined(OS_WIN) |
| 57 ReplaceSubstringsAfterOffset(&str_path, 0u, "\\", "/"); | 57 ReplaceSubstringsAfterOffset(&str_path, 0u, "\\", "/"); |
| 58 #endif | 58 #endif |
| 59 | 59 |
| 60 bool is_directory = file_util::DirectoryExists(path); | 60 bool is_directory = file_util::DirectoryExists(path); |
| 61 if (is_directory) | 61 if (is_directory) |
| 62 str_path += "/"; | 62 str_path += "/"; |
| 63 | 63 |
| 64 if (ZIP_OK != zipOpenNewFileInZip( | 64 if (ZIP_OK != zipOpenNewFileInZip( |
| 65 zip_file, str_path.c_str(), | 65 zip_file, str_path.c_str(), |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 if (ZIP_OK != zipClose(zip_file, NULL)) { | 198 if (ZIP_OK != zipClose(zip_file, NULL)) { |
| 199 DLOG(ERROR) << "Error closing zip file for fd " << dest_fd; | 199 DLOG(ERROR) << "Error closing zip file for fd " << dest_fd; |
| 200 success = false; | 200 success = false; |
| 201 } | 201 } |
| 202 | 202 |
| 203 return success; | 203 return success; |
| 204 } | 204 } |
| 205 #endif // defined(OS_POSIX) | 205 #endif // defined(OS_POSIX) |
| 206 | 206 |
| 207 } // namespace zip | 207 } // namespace zip |
| OLD | NEW |