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: debugging int64_t on android 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..062c37383b6c0bda0e7a3f6b3d6e75990db84fa4 100644
--- a/third_party/zlib/google/zip_reader.h
+++ b/third_party/zlib/google/zip_reader.h
@@ -159,8 +159,13 @@ 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|.
- 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 file is too large to be extracted to |delegate| or if file
+ // is too small to fill |num_bytes_to_extract|.
+ bool ExtractCurrentEntry(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
@@ -202,20 +207,22 @@ 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.
- bool ExtractCurrentEntryToString(
- size_t max_read_bytes,
- std::string* output) 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. 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. If |read_entire_file| is true, then
+ // |num_bytes| limits the ammount of memory used to carry the entry, and false
+ // is returned if the real size of the uncompressed data is bigger than
+ // |max_read_bytes|. Otherwise if |read_entire_file| is false, |num_bytes|
satorux1 2017/07/25 07:55:15 nit: num_bytes and max_read_bytes are not consiste
mortonm 2017/07/25 18:10:15 Done.
+ // signifies the number of bytes to read from the file, and false is returned
+ // if the real size of the uncompressed data is smaller than |max_read_bytes|.
+ bool ExtractCurrentEntryToString(size_t num_bytes,
+ bool read_entire_file,
satorux1 2017/07/25 07:55:15 zip_analyzier is the only caller of this function,
mortonm 2017/07/25 18:10:15 Done, I agree, this is a better way of writing thi
+ std::string* output) const;
// Returns the current entry info. Returns NULL if the current entry is
// not yet opened. OpenCurrentEntryInZip() must be called beforehand.
« no previous file with comments | « chrome/test/data/safe_browsing/mach_o/zipped-app-two-executables-one-signed.zip ('k') | third_party/zlib/google/zip_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698