blob: 49fb902a7408e7f83fcd8a3a66b6db93c76ce67f [file] [log] [blame]
alecflett@chromium.orgd6d082e2013-05-03 23:02:57 +00001// 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
aviaa969482015-12-27 13:36:49 -08008#include <string>
9
Jay Civelli4f9e8e82017-10-13 16:38:08 +000010#include "base/time/time.h"
aviaa969482015-12-27 13:36:49 -080011#include "build/build_config.h"
12
alecflett@chromium.orgd6d082e2013-05-03 23:02:57 +000013#if defined(OS_WIN)
14#include <windows.h>
15#endif
16
alecflett@chromium.orgd6d082e2013-05-03 23:02:57 +000017#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.com16b1df32014-05-02 16:50:09 +000025namespace base {
26class FilePath;
27}
28
alecflett@chromium.orgd6d082e2013-05-03 23:02:57 +000029// Utility functions and constants used internally for the zip file
30// library in the directory. Don't use them outside of the library.
31namespace zip {
32namespace internal {
33
34// Opens the given file name in UTF-8 for unzipping, with some setup for
35// Windows.
36unzFile OpenForUnzipping(const std::string& file_name_utf8);
37
38#if defined(OS_POSIX)
39// Opens the file referred to by |zip_fd| for unzipping.
40unzFile OpenFdForUnzipping(int zip_fd);
41#endif
42
43#if defined(OS_WIN)
44// Opens the file referred to by |zip_handle| for unzipping.
45unzFile 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.com16b1df32014-05-02 16:50:09 +000051unzFile PrepareMemoryForUnzipping(const std::string& data);
alecflett@chromium.orgd6d082e2013-05-03 23:02:57 +000052
53// Opens the given file name in UTF-8 for zipping, with some setup for
54// Windows. |append_flag| will be passed to zipOpen2().
55zipFile 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().
60zipFile OpenFdForZipping(int zip_fd, int append_flag);
61#endif
62
joaoe@opera.com16b1df32014-05-02 16:50:09 +000063// Wrapper around zipOpenNewFileInZip4 which passes most common options.
64bool ZipOpenNewFileInZip(zipFile zip_file,
65 const std::string& str_path,
Jay Civelli4f9e8e82017-10-13 16:38:08 +000066 base::Time last_modified_time);
joaoe@opera.com16b1df32014-05-02 16:50:09 +000067
alecflett@chromium.orgd6d082e2013-05-03 23:02:57 +000068const int kZipMaxPath = 256;
69const int kZipBufSize = 8192;
70
71} // namespace internal
72} // namespace zip
73
74#endif // THIRD_PARTY_ZLIB_GOOGLE_ZIP_INTERNAL_H_