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

Side by Side Diff: third_party/zlib/google/zip_reader.h

Issue 2961373002: Improve Zip File Scanning on Mac (Closed)
Patch Set: removing check for .app on windows 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 #ifndef THIRD_PARTY_ZLIB_GOOGLE_ZIP_READER_H_ 4 #ifndef THIRD_PARTY_ZLIB_GOOGLE_ZIP_READER_H_
5 #define THIRD_PARTY_ZLIB_GOOGLE_ZIP_READER_H_ 5 #define THIRD_PARTY_ZLIB_GOOGLE_ZIP_READER_H_
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 bool OpenCurrentEntryInZip(); 155 bool OpenCurrentEntryInZip();
156 156
157 // Locates an entry in the zip file and opens it. Returns true on 157 // Locates an entry in the zip file and opens it. Returns true on
158 // success. This function internally calls OpenCurrentEntryInZip() on 158 // success. This function internally calls OpenCurrentEntryInZip() on
159 // success. On failure, current_entry_info() becomes NULL. 159 // success. On failure, current_entry_info() becomes NULL.
160 bool LocateAndOpenEntry(const base::FilePath& path_in_zip); 160 bool LocateAndOpenEntry(const base::FilePath& path_in_zip);
161 161
162 // Extracts the current entry in chunks to |delegate|. 162 // Extracts the current entry in chunks to |delegate|.
163 bool ExtractCurrentEntry(WriterDelegate* delegate) const; 163 bool ExtractCurrentEntry(WriterDelegate* delegate) const;
164 164
165 // Extracts part of the current entry to |delegate|, starting from the
166 // beginning of the entry.
167 bool ExtractPartOfCurrentEntry(WriterDelegate* delegate,
168 size_t num_bytes) const;
satorux1 2017/07/14 01:00:53 Could you add a unit test for this function to zip
mortonm 2017/07/14 17:08:45 Done.
169
165 // Extracts the current entry to the given output file path. If the 170 // Extracts the current entry to the given output file path. If the
166 // current file is a directory, just creates a directory 171 // current file is a directory, just creates a directory
167 // instead. Returns true on success. OpenCurrentEntryInZip() must be 172 // instead. Returns true on success. OpenCurrentEntryInZip() must be
168 // called beforehand. 173 // called beforehand.
169 // 174 //
170 // This function preserves the timestamp of the original entry. If that 175 // This function preserves the timestamp of the original entry. If that
171 // timestamp is not valid, the timestamp will be set to the current time. 176 // timestamp is not valid, the timestamp will be set to the current time.
172 bool ExtractCurrentEntryToFilePath( 177 bool ExtractCurrentEntryToFilePath(
173 const base::FilePath& output_file_path) const; 178 const base::FilePath& output_file_path) const;
174 179
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // passing it around by value, but by reference or pointer. 215 // passing it around by value, but by reference or pointer.
211 // Note: the value returned by EntryInfo::original_size() cannot be 216 // Note: the value returned by EntryInfo::original_size() cannot be
212 // trusted, so the real size of the uncompressed contents can be different. 217 // trusted, so the real size of the uncompressed contents can be different.
213 // Use max_read_bytes to limit the ammount of memory used to carry the entry. 218 // Use max_read_bytes to limit the ammount of memory used to carry the entry.
214 // If the real size of the uncompressed data is bigger than max_read_bytes 219 // If the real size of the uncompressed data is bigger than max_read_bytes
215 // then false is returned. |max_read_bytes| must be non-zero. 220 // then false is returned. |max_read_bytes| must be non-zero.
216 bool ExtractCurrentEntryToString( 221 bool ExtractCurrentEntryToString(
217 size_t max_read_bytes, 222 size_t max_read_bytes,
218 std::string* output) const; 223 std::string* output) const;
219 224
225 // Same as ExtractCurrentEntryToString(), except specifies the number of bytes
226 // to read into the string so that it is possible to only read a partial
227 // amount of the entry into a string. This is used to infer the type of
228 // MachO files on Mac by sniffing their magic number in the header.
229 bool ExtractPartOfCurrentEntryToString(size_t max_read_bytes,
satorux1 2017/07/14 01:00:53 Ditto.
mortonm 2017/07/14 17:08:45 Done.
230 std::string* output) const;
231
220 // Returns the current entry info. Returns NULL if the current entry is 232 // Returns the current entry info. Returns NULL if the current entry is
221 // not yet opened. OpenCurrentEntryInZip() must be called beforehand. 233 // not yet opened. OpenCurrentEntryInZip() must be called beforehand.
222 EntryInfo* current_entry_info() const { 234 EntryInfo* current_entry_info() const {
223 return current_entry_info_.get(); 235 return current_entry_info_.get();
224 } 236 }
225 237
226 // Returns the number of entries in the zip file. 238 // Returns the number of entries in the zip file.
227 // Open() must be called beforehand. 239 // Open() must be called beforehand.
228 int num_entries() const { return num_entries_; } 240 int num_entries() const { return num_entries_; }
229 241
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 private: 284 private:
273 base::File* file_; 285 base::File* file_;
274 int64_t file_length_; 286 int64_t file_length_;
275 287
276 DISALLOW_COPY_AND_ASSIGN(FileWriterDelegate); 288 DISALLOW_COPY_AND_ASSIGN(FileWriterDelegate);
277 }; 289 };
278 290
279 } // namespace zip 291 } // namespace zip
280 292
281 #endif // THIRD_PARTY_ZLIB_GOOGLE_ZIP_READER_H_ 293 #endif // THIRD_PARTY_ZLIB_GOOGLE_ZIP_READER_H_
OLDNEW
« no previous file with comments | « chrome/test/data/safe_browsing/mach_o/zipped-app-with-executable.zip ('k') | third_party/zlib/google/zip_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698