OLD | NEW |
1 // Copyright (c) 2011 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/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "third_party/zlib/contrib/minizip/unzip.h" | 8 #include "third_party/zlib/contrib/minizip/unzip.h" |
9 #include "third_party/zlib/contrib/minizip/zip.h" | 9 #include "third_party/zlib/contrib/minizip/zip.h" |
10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 zlib_filefunc_def* zip_func_ptrs = NULL; | 74 zlib_filefunc_def* zip_func_ptrs = NULL; |
75 #if defined(OS_WIN) | 75 #if defined(OS_WIN) |
76 zlib_filefunc_def zip_funcs; | 76 zlib_filefunc_def zip_funcs; |
77 fill_win32_filefunc(&zip_funcs); | 77 fill_win32_filefunc(&zip_funcs); |
78 zip_funcs.zopen_file = ZipOpenFunc; | 78 zip_funcs.zopen_file = ZipOpenFunc; |
79 zip_func_ptrs = &zip_funcs; | 79 zip_func_ptrs = &zip_funcs; |
80 #endif | 80 #endif |
81 return unzOpen2(file_name_utf8.c_str(), zip_func_ptrs); | 81 return unzOpen2(file_name_utf8.c_str(), zip_func_ptrs); |
82 } | 82 } |
83 | 83 |
| 84 #if defined(OS_POSIX) |
| 85 unzFile OpenFdForUnzipping(int zip_fd) { |
| 86 zlib_filefunc_def zip_funcs; |
| 87 fill_fdopen_filefunc(&zip_funcs, zip_fd); |
| 88 // Passing dummy "fd" filename to zlib. |
| 89 return unzOpen2("fd", &zip_funcs); |
| 90 } |
| 91 #endif |
| 92 |
84 zipFile OpenForZipping(const std::string& file_name_utf8, int append_flag) { | 93 zipFile OpenForZipping(const std::string& file_name_utf8, int append_flag) { |
85 zlib_filefunc_def* zip_func_ptrs = NULL; | 94 zlib_filefunc_def* zip_func_ptrs = NULL; |
86 #if defined(OS_WIN) | 95 #if defined(OS_WIN) |
87 zlib_filefunc_def zip_funcs; | 96 zlib_filefunc_def zip_funcs; |
88 fill_win32_filefunc(&zip_funcs); | 97 fill_win32_filefunc(&zip_funcs); |
89 zip_funcs.zopen_file = ZipOpenFunc; | 98 zip_funcs.zopen_file = ZipOpenFunc; |
90 zip_func_ptrs = &zip_funcs; | 99 zip_func_ptrs = &zip_funcs; |
91 #endif | 100 #endif |
92 return zipOpen2(file_name_utf8.c_str(), | 101 return zipOpen2(file_name_utf8.c_str(), |
93 append_flag, | 102 append_flag, |
94 NULL, // global comment | 103 NULL, // global comment |
95 zip_func_ptrs); | 104 zip_func_ptrs); |
96 } | 105 } |
97 | 106 |
98 } // namespace internal | 107 } // namespace internal |
99 } // namespace zip | 108 } // namespace zip |
OLD | NEW |