summaryrefslogtreecommitdiff
path: root/google/zip_reader.h
diff options
context:
space:
mode:
authorbenwells <benwells@chromium.org>2015-03-17 19:32:09 -0700
committerCommit bot <commit-bot@chromium.org>2015-03-18 02:33:09 +0000
commit8da8b87d318bc46d29ba32566d7e92ac32b1ed38 (patch)
treec2880e5fdb46d38ec15c011ce501f93628d7637d /google/zip_reader.h
parent57cb1f8568cc6181356583e24a09681f4db71ab6 (diff)
downloadzlib-8da8b87d318bc46d29ba32566d7e92ac32b1ed38.tar.gz
Revert of Add ZipReader::ExtractCurrentEntry with a delegate interface. (patchset #2 id:40001 of https://codereview.chromium.org/1014653002/)
Reason for revert: There are uninitialized reads on the DrMemory bots in zlib ZipTests. They have very little information, and there is no history available due to a bot problem. Experimentally reverting this CL to see if it helps. Original issue's description: > Add ZipReader::ExtractCurrentEntry with a delegate interface. > > This change gives consumers of ZipReader a way to have the current entry > streamed to them via a Delegate interface. It also: > > - Reduces duplication in the ExtractCurrentEntry* functions. > - Uses the heap rather than the stack for intermediate buffers. > - Changes ExtractCurrentEntryToFd to ExtractCurrentEntryToFile, making > it cross-platform in the process. > > BUG=462584 > > Committed: https://crrev.com/2919be01ff758875fc7161f6b41f4461518c1213 > Cr-Commit-Position: refs/heads/master@{#320948} TBR=hshi@chromium.org,grt@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=462584 Review URL: https://codereview.chromium.org/1016813004 Cr-Original-Commit-Position: refs/heads/master@{#321059} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 1369bc06458c9e803307ddc7aaec0d71e4a938ab
Diffstat (limited to 'google/zip_reader.h')
-rw-r--r--google/zip_reader.h55
1 files changed, 7 insertions, 48 deletions
diff --git a/google/zip_reader.h b/google/zip_reader.h
index da6cc93..9280f23 100644
--- a/google/zip_reader.h
+++ b/google/zip_reader.h
@@ -23,21 +23,6 @@
namespace zip {
-// A delegate interface used to stream out an entry; see
-// ZipReader::ExtractCurrentEntry.
-class WriterDelegate {
- public:
- virtual ~WriterDelegate() {}
-
- // Invoked once before any data is streamed out to pave the way (e.g., to open
- // the output file). Return false on failure to cancel extraction.
- virtual bool PrepareOutput() = 0;
-
- // Invoked to write the next chunk of data. Return false on failure to cancel
- // extraction.
- virtual bool WriteBytes(const char* data, int num_bytes) = 0;
-};
-
// This class is used for reading zip files. A typical use case of this
// class is to scan entries in a zip file and extract them. The code will
// look like:
@@ -156,9 +141,6 @@ 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 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
@@ -166,8 +148,7 @@ class ZipReader {
//
// This function preserves the timestamp of the original entry. If that
// timestamp is not valid, the timestamp will be set to the current time.
- bool ExtractCurrentEntryToFilePath(
- const base::FilePath& output_file_path) const;
+ bool ExtractCurrentEntryToFilePath(const base::FilePath& output_file_path);
// Asynchronously extracts the current entry to the given output file path.
// If the current entry is a directory it just creates the directory
@@ -193,11 +174,13 @@ class ZipReader {
// This function preserves the timestamp of the original entry. If that
// timestamp is not valid, the timestamp will be set to the current time.
bool ExtractCurrentEntryIntoDirectory(
- const base::FilePath& output_directory_path) const;
+ const base::FilePath& output_directory_path);
- // Extracts the current entry by writing directly to a platform file.
- // Does not close the file. Returns true on success.
- bool ExtractCurrentEntryToFile(base::File* file) const;
+#if defined(OS_POSIX)
+ // Extracts the current entry by writing directly to a file descriptor.
+ // Does not close the file descriptor. Returns true on success.
+ 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
@@ -249,30 +232,6 @@ class ZipReader {
DISALLOW_COPY_AND_ASSIGN(ZipReader);
};
-// A writer delegate that writes to a given File.
-class FileWriterDelegate : public WriterDelegate {
- public:
- explicit FileWriterDelegate(base::File* file);
-
- // Truncates the file to the number of bytes written.
- ~FileWriterDelegate() override;
-
- // WriterDelegate methods:
-
- // Seeks to the beginning of the file, returning false if the seek fails.
- bool PrepareOutput() override;
-
- // Writes |num_bytes| bytes of |data| to the file, returning false on error or
- // if not all bytes could be written.
- bool WriteBytes(const char* data, int num_bytes) override;
-
- private:
- base::File* file_;
- int64_t file_length_;
-
- DISALLOW_COPY_AND_ASSIGN(FileWriterDelegate);
-};
-
} // namespace zip
#endif // THIRD_PARTY_ZLIB_GOOGLE_ZIP_READER_H_