alecflett@chromium.org | d6d082e | 2013-05-03 23:02:57 +0000 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef THIRD_PARTY_ZLIB_GOOGLE_ZIP_INTERNAL_H_ |
| 6 | #define THIRD_PARTY_ZLIB_GOOGLE_ZIP_INTERNAL_H_ |
| 7 | |
avi | aa96948 | 2015-12-27 13:36:49 -0800 | [diff] [blame] | 8 | #include <string> |
| 9 | |
Jay Civelli | 4f9e8e8 | 2017-10-13 16:38:08 +0000 | [diff] [blame] | 10 | #include "base/time/time.h" |
avi | aa96948 | 2015-12-27 13:36:49 -0800 | [diff] [blame] | 11 | #include "build/build_config.h" |
| 12 | |
alecflett@chromium.org | d6d082e | 2013-05-03 23:02:57 +0000 | [diff] [blame] | 13 | #if defined(OS_WIN) |
| 14 | #include <windows.h> |
| 15 | #endif |
| 16 | |
alecflett@chromium.org | d6d082e | 2013-05-03 23:02:57 +0000 | [diff] [blame] | 17 | #if defined(USE_SYSTEM_MINIZIP) |
| 18 | #include <minizip/unzip.h> |
| 19 | #include <minizip/zip.h> |
| 20 | #else |
| 21 | #include "third_party/zlib/contrib/minizip/unzip.h" |
| 22 | #include "third_party/zlib/contrib/minizip/zip.h" |
| 23 | #endif |
| 24 | |
joaoe@opera.com | 16b1df3 | 2014-05-02 16:50:09 +0000 | [diff] [blame] | 25 | namespace base { |
| 26 | class FilePath; |
| 27 | } |
| 28 | |
alecflett@chromium.org | d6d082e | 2013-05-03 23:02:57 +0000 | [diff] [blame] | 29 | // Utility functions and constants used internally for the zip file |
| 30 | // library in the directory. Don't use them outside of the library. |
| 31 | namespace zip { |
| 32 | namespace internal { |
| 33 | |
| 34 | // Opens the given file name in UTF-8 for unzipping, with some setup for |
| 35 | // Windows. |
| 36 | unzFile OpenForUnzipping(const std::string& file_name_utf8); |
| 37 | |
| 38 | #if defined(OS_POSIX) |
| 39 | // Opens the file referred to by |zip_fd| for unzipping. |
| 40 | unzFile OpenFdForUnzipping(int zip_fd); |
| 41 | #endif |
| 42 | |
| 43 | #if defined(OS_WIN) |
| 44 | // Opens the file referred to by |zip_handle| for unzipping. |
| 45 | unzFile OpenHandleForUnzipping(HANDLE zip_handle); |
| 46 | #endif |
| 47 | |
| 48 | // Creates a custom unzFile object which reads data from the specified string. |
| 49 | // This custom unzFile object overrides the I/O API functions of zlib so it can |
| 50 | // read data from the specified string. |
joaoe@opera.com | 16b1df3 | 2014-05-02 16:50:09 +0000 | [diff] [blame] | 51 | unzFile PrepareMemoryForUnzipping(const std::string& data); |
alecflett@chromium.org | d6d082e | 2013-05-03 23:02:57 +0000 | [diff] [blame] | 52 | |
| 53 | // Opens the given file name in UTF-8 for zipping, with some setup for |
| 54 | // Windows. |append_flag| will be passed to zipOpen2(). |
| 55 | zipFile OpenForZipping(const std::string& file_name_utf8, int append_flag); |
| 56 | |
| 57 | #if defined(OS_POSIX) |
| 58 | // Opens the file referred to by |zip_fd| for zipping. |append_flag| will be |
| 59 | // passed to zipOpen2(). |
| 60 | zipFile OpenFdForZipping(int zip_fd, int append_flag); |
| 61 | #endif |
| 62 | |
joaoe@opera.com | 16b1df3 | 2014-05-02 16:50:09 +0000 | [diff] [blame] | 63 | // Wrapper around zipOpenNewFileInZip4 which passes most common options. |
| 64 | bool ZipOpenNewFileInZip(zipFile zip_file, |
| 65 | const std::string& str_path, |
Jay Civelli | 4f9e8e8 | 2017-10-13 16:38:08 +0000 | [diff] [blame] | 66 | base::Time last_modified_time); |
joaoe@opera.com | 16b1df3 | 2014-05-02 16:50:09 +0000 | [diff] [blame] | 67 | |
alecflett@chromium.org | d6d082e | 2013-05-03 23:02:57 +0000 | [diff] [blame] | 68 | const int kZipMaxPath = 256; |
| 69 | const int kZipBufSize = 8192; |
| 70 | |
| 71 | } // namespace internal |
| 72 | } // namespace zip |
| 73 | |
| 74 | #endif // THIRD_PARTY_ZLIB_GOOGLE_ZIP_INTERNAL_H_ |