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

Unified Diff: chrome/common/zip_reader.h

Issue 8873039: Add an API to unpack Zip files directly from and to file descriptors. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 years 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: chrome/common/zip_reader.h
diff --git a/chrome/common/zip_reader.h b/chrome/common/zip_reader.h
index f77616ba9f96c7d4d74313b351dab1946b9b78f9..2fe90dcbfeb277a86fb3293bdb3eea8549c960c6 100644
--- a/chrome/common/zip_reader.h
+++ b/chrome/common/zip_reader.h
@@ -10,6 +10,7 @@
#include "base/basictypes.h"
#include "base/file_path.h"
+#include "base/file_util.h"
#include "base/memory/scoped_ptr.h"
#include "base/time.h"
#include "third_party/zlib/contrib/minizip/unzip.h"
@@ -77,6 +78,12 @@ class ZipReader {
// success.
bool Open(const FilePath& zip_file_path);
+#if defined(OS_POSIX)
+ // Opens the zip file referred to by the file descriptor |zip_fd|.
+ // Returns true on success.
+ bool OpenFd(const int zip_fd);
satorux1 2011/12/12 04:54:14 We often use "FromSomething" for naming functions
Jorge Lucangeli Obes 2011/12/12 23:34:35 Done.
+#endif
+
// Closes the currently opened zip file. This function is called in the
// destructor of the class, so you usually don't need to call this.
void Close();
@@ -125,6 +132,12 @@ class ZipReader {
// beforehand.
bool ExtractCurrentEntryIntoDirectory(const FilePath& output_directory_path);
+#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(const int fd);
+#endif
+
// 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 {
@@ -136,9 +149,15 @@ class ZipReader {
int num_entries() const { return num_entries_; }
private:
+ // Initializes internal state.
+ bool Initialize();
+
// Resets the internal state.
void Reset();
+ // Helper for ExtractCurrentEntryTo(FilePath|Fd)
+ bool ExtractCurrentEntryToBuffer(const char* buf, const int size);
+
unzFile zip_file_;
int num_entries_;
bool reached_end_;

Powered by Google App Engine
This is Rietveld 408576698