Chromium Code Reviews| Index: third_party/zlib/google/zip_internal.h |
| diff --git a/third_party/zlib/google/zip_internal.h b/third_party/zlib/google/zip_internal.h |
| index 57894bebd6459390504e49a05cda92788d9301ba..693b9a36301ed230ea4dfd4f71383804c0bbee13 100644 |
| --- a/third_party/zlib/google/zip_internal.h |
| +++ b/third_party/zlib/google/zip_internal.h |
| @@ -9,8 +9,11 @@ |
| #include <windows.h> |
| #endif |
| +#include <map> |
| #include <string> |
| +#include "base/strings/string_piece.h" |
| + |
| #if defined(USE_SYSTEM_MINIZIP) |
| #include <minizip/unzip.h> |
| #include <minizip/zip.h> |
| @@ -19,6 +22,11 @@ |
| #include "third_party/zlib/contrib/minizip/zip.h" |
| #endif |
| +namespace base { |
| +class FilePath; |
| +class Time; |
| +} |
| + |
| // Utility functions and constants used internally for the zip file |
| // library in the directory. Don't use them outside of the library. |
| namespace zip { |
| @@ -41,7 +49,7 @@ unzFile OpenHandleForUnzipping(HANDLE zip_handle); |
| // Creates a custom unzFile object which reads data from the specified string. |
| // This custom unzFile object overrides the I/O API functions of zlib so it can |
| // read data from the specified string. |
| -unzFile PreprareMemoryForUnzipping(const std::string& data); |
| +unzFile PrepareMemoryForUnzipping(const std::string& data); |
| // Opens the given file name in UTF-8 for zipping, with some setup for |
| // Windows. |append_flag| will be passed to zipOpen2(). |
| @@ -53,6 +61,41 @@ zipFile OpenForZipping(const std::string& file_name_utf8, int append_flag); |
| zipFile OpenFdForZipping(int zip_fd, int append_flag); |
| #endif |
| +// Returns a zip_fileinfo with the last modification date of |path| set. |
| +zip_fileinfo GetFileInfoForZipping(const base::FilePath& path); |
| + |
| +// Wrapper around zipOpenNewFileInZip4 which passes most common options. |
| +bool ZipOpenNewFileInZipWrapper(zipFile zip_file, |
| + const std::string& str_path, |
| + const zip_fileinfo* file_info); |
| + |
| +// Adds to |zip_file| files using contents from memory. |zip_file| is created if |
| +// it does not exist. |files| contains a map with the file path to |
| +// be stored in the zip file plus its contents. The FilePath in |files| may not |
| +// be empty, absolute or contain a '..' component, else the function fails. |
| +// The paths must therefore be relative and preferably canonicalized. |
| +// Calling this with an empty |files| has no effect. |
| +// |
| +// If |append| is true, the new files are appended to an already existing file, |
| +// if any. Else, the file is recreated from scratch, meaning, all previous |
| +// contents are deleted without the possibility of recovery. |
| +// |
| +// If the StringPiece in |files| is NULL, the file is removed from the zip |
| +// archive. If the StringPiece in |files| is not NULL, a file will be |
| +// created with those contents. The contents can have a size of 0 bytes. |
| +// Note: the data passed in |files| is copied to the file. This function does |
| +// not keep any references to the original data after it returns. |
| +// |
| +// If the FilePath ends with a path separator (a slash), a folder is created. |
| +// Note: the contents for a folder must be either NULL or 0-byte big, so the |
| +// folder will be removed or added, respectively. |
| + |
| +typedef std::map<const base::FilePath, base::StringPiece> ZipContents; |
| + |
| +bool ZipFromMemory(const base::FilePath& zip_path, |
| + const ZipContents& files, |
| + bool append); |
| + |
|
satorux1
2014/03/24 06:16:07
Could you create a separate patch for this?
|
| const int kZipMaxPath = 256; |
| const int kZipBufSize = 8192; |