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#if defined(OS_WIN) 9#include <windows.h> 10#endif 11 12#include <string> 13 14#if defined(USE_SYSTEM_MINIZIP) 15#include <minizip/unzip.h> 16#include <minizip/zip.h> 17#else 18#include "third_party/zlib/contrib/minizip/unzip.h" 19#include "third_party/zlib/contrib/minizip/zip.h" 20#endif 21 22namespace base { 23class FilePath; 24} 25 26// Utility functions and constants used internally for the zip file 27// library in the directory. Don't use them outside of the library. 28namespace zip { 29namespace internal { 30 31// Opens the given file name in UTF-8 for unzipping, with some setup for 32// Windows. 33unzFile OpenForUnzipping(const std::string& file_name_utf8); 34 35#if defined(OS_POSIX) 36// Opens the file referred to by |zip_fd| for unzipping. 37unzFile OpenFdForUnzipping(int zip_fd); 38#endif 39 40#if defined(OS_WIN) 41// Opens the file referred to by |zip_handle| for unzipping. 42unzFile OpenHandleForUnzipping(HANDLE zip_handle); 43#endif 44 45// Creates a custom unzFile object which reads data from the specified string. 46// This custom unzFile object overrides the I/O API functions of zlib so it can 47// read data from the specified string. 48unzFile PrepareMemoryForUnzipping(const std::string& data); 49 50// Opens the given file name in UTF-8 for zipping, with some setup for 51// Windows. |append_flag| will be passed to zipOpen2(). 52zipFile OpenForZipping(const std::string& file_name_utf8, int append_flag); 53 54#if defined(OS_POSIX) 55// Opens the file referred to by |zip_fd| for zipping. |append_flag| will be 56// passed to zipOpen2(). 57zipFile OpenFdForZipping(int zip_fd, int append_flag); 58#endif 59 60// Returns a zip_fileinfo with the last modification date of |path| set. 61zip_fileinfo GetFileInfoForZipping(const base::FilePath& path); 62 63// Wrapper around zipOpenNewFileInZip4 which passes most common options. 64bool ZipOpenNewFileInZip(zipFile zip_file, 65 const std::string& str_path, 66 const zip_fileinfo* file_info); 67 68const int kZipMaxPath = 256; 69const int kZipBufSize = 8192; 70 71} // namespace internal 72} // namespace zip 73 74#endif // THIRD_PARTY_ZLIB_GOOGLE_ZIP_INTERNAL_H_ 75