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

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: Lint fixes. 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..076565105f139dd035bc4fb60e779d8655afda78 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 OpenFromFd(int zip_fd);
+#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(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:
+ // Common code used both in Open and OpenFromFd.
+ bool OpenInternal();
+
// Resets the internal state.
void Reset();
+ // Helper for ExtractCurrentEntryTo(FilePath|Fd)
+ bool ExtractCurrentEntryToBuffer(const char* buf, const int size);
satorux1 2011/12/13 05:23:08 Unused? I guess you wanted to factor out the loop
Jorge Lucangeli Obes 2011/12/14 23:17:55 Done.
+
unzFile zip_file_;
int num_entries_;
bool reached_end_;

Powered by Google App Engine
This is Rietveld 408576698