Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1399)

Unified Diff: third_party/zlib/google/zip_reader.h

Issue 292443006: New ZipReader::ExtractCurrentEntryToString API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src
Patch Set: rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/zlib/google/zip_reader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/zlib/google/zip_reader.h
diff --git a/third_party/zlib/google/zip_reader.h b/third_party/zlib/google/zip_reader.h
index 60b53ee6e660ac3f7aee4e09b57ac9b950148e9d..fa4186bbc4e70b2e0a033c4eb6b820233faea558 100644
--- a/third_party/zlib/google/zip_reader.h
+++ b/third_party/zlib/google/zip_reader.h
@@ -35,7 +35,7 @@ namespace zip {
// reader.AdvanceToNextEntry();
// }
//
-// For simplicty, error checking is omitted in the example code above. The
+// For simplicity, error checking is omitted in the example code above. The
// production code should check return values from all of these functions.
//
// This calls can also be used for random access of contents in a zip file
@@ -182,6 +182,21 @@ class ZipReader {
bool ExtractCurrentEntryToFd(int fd);
#endif
+ // Extracts the current entry into memory. If the current entry is a directory
+ // the |output| parameter is set to the empty string. If the current entry is
+ // a file, the |output| parameter is filled with its contents. Returns true on
+ // success. OpenCurrentEntryInZip() must be called beforehand.
+ // Note: the |output| parameter can be filled with a big amount of data, avoid
+ // passing it around by value, but by reference or pointer.
+ // Note: the value returned by EntryInfo::original_size() cannot be
+ // trusted, so the real size of the uncompressed contents can be different.
+ // Use max_read_bytes to limit the ammount of memory used to carry the entry.
+ // If the real size of the uncompressed data is bigger than max_read_bytes
+ // then false is returned. |max_read_bytes| must be non-zero.
+ bool ExtractCurrentEntryToString(
+ size_t max_read_bytes,
+ std::string* output) const;
+
// Returns the current entry info. Returns NULL if the current entry is
// not yet opened. OpenCurrentEntryInZip() must be called beforehand.
EntryInfo* current_entry_info() const {
« no previous file with comments | « no previous file | third_party/zlib/google/zip_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698