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 8 #include <string> 9 10 #include "base/time/time.h" 11 #include "build/build_config.h" 12 13 #if defined(OS_WIN) 14 #include <windows.h> 15 #endif 16 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 25 namespace base { 26 class FilePath; 27 } 28 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. 51 unzFile PrepareMemoryForUnzipping(const std::string& data); 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 63 // Wrapper around zipOpenNewFileInZip4 which passes most common options. 64 bool ZipOpenNewFileInZip(zipFile zip_file, 65 const std::string& str_path, 66 base::Time last_modified_time); 67 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_ 75