zip_internal.h 2.2 KB

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