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

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

Issue 2961373002: Improve Zip File Scanning on Mac (Closed)
Patch Set: refactoring in zip_reader Created 3 years, 5 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
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 c1b6fb3364abeba3c34231e9dd1fea500540029e..49b81ee2da19861a3f61bf7711e8b2e6cb7332a8 100644
--- a/third_party/zlib/google/zip_reader.h
+++ b/third_party/zlib/google/zip_reader.h
@@ -159,9 +159,16 @@ class ZipReader {
// success. On failure, current_entry_info() becomes NULL.
bool LocateAndOpenEntry(const base::FilePath& path_in_zip);
- // Extracts the current entry in chunks to |delegate|.
+ // Extracts entirety of the current entry in chunks to |delegate|.
satorux1 2017/07/21 05:27:02 While you are at it, could you add documentation a
mortonm 2017/07/21 16:29:56 Done. Didn't add an explanation here, but there ar
bool ExtractCurrentEntry(WriterDelegate* delegate) const;
+ // Extracts |num_bytes_to_extract| bytes of the current entry to |delegate|,
+ // starting from the beginning of the entry. A negative value for
+ // |num_bytes_to_extract| means the entire current entry will be extracted.
+ // Returns false if |num_bytes_to_extract| is greater than file length.
+ bool ExtractFromBeginningOfCurrentEntry(WriterDelegate* delegate,
+ int64_t num_bytes_to_extract) const;
+
// Extracts the current entry to the given output file path. If the
// current file is a directory, just creates a directory
// instead. Returns true on success. OpenCurrentEntryInZip() must be
@@ -202,21 +209,30 @@ class ZipReader {
// Does not close the file. Returns true on success.
bool ExtractCurrentEntryToFile(base::File* file) const;
- // 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.
+ // 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;
+ // Same as ExtractCurrentEntryToString(), except specifies the number of bytes
+ // to read into the string so that it is possible to only read a partial
+ // amount of the entry into a string. If
+ // |read_entire_file|, returns true only if |num_bytes_to_extract| is at least
+ // the size of entire file.
+ bool ExtractFromBeginningOfCurrentEntryToString(size_t num_bytes_to_extract,
+ bool read_entire_file,
+ 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 {

Powered by Google App Engine
This is Rietveld 408576698