| Index: ui/file_manager/zip_archiver/cpp/compressor_archive_libarchive.h
|
| diff --git a/ui/file_manager/zip_archiver/cpp/compressor_archive_libarchive.h b/ui/file_manager/zip_archiver/cpp/compressor_archive_libarchive.h
|
| index b0a299da65f31e155deeff76177a8cbdb242132c..13e3c48e52b843fcec7e25b837684207cf3b0803 100644
|
| --- a/ui/file_manager/zip_archiver/cpp/compressor_archive_libarchive.h
|
| +++ b/ui/file_manager/zip_archiver/cpp/compressor_archive_libarchive.h
|
| @@ -7,17 +7,37 @@
|
|
|
| #include <string>
|
|
|
| -#include "archive.h"
|
| +#include "third_party/zlib/contrib/minizip/unzip.h"
|
| +#include "third_party/zlib/contrib/minizip/zip.h"
|
|
|
| #include "compressor_archive.h"
|
| #include "compressor_stream.h"
|
|
|
| // A namespace with constants used by CompressorArchiveLibarchive.
|
| namespace compressor_archive_constants {
|
| -const int64_t kMaximumDataChunkSize = 512 * 1024;
|
| -const int kFilePermission = 640;
|
| -const int kDirectoryPermission = 760;
|
| -} // namespace compressor_archive_constants
|
| +
|
| +const char kCreateArchiveError[] = "Failed to create archive.";
|
| +const char kAddToArchiveError[] = "Failed to add entry to archive.";
|
| +const char kCloseArchiveError[] = "Failed to close archive.";
|
| +
|
| +}
|
| +
|
| +// A name space with custom functions passed to minizip.
|
| +namespace compressor_archive_functions {
|
| +
|
| + uLong CustomArchiveWrite(void* compressor,
|
| + void* stream,
|
| + const void* buffer,
|
| + uLong length);
|
| +
|
| + long CustomArchiveTell(void* compressor, void* stream);
|
| +
|
| + long CustomArchiveSeek(void* compressor,
|
| + void* stream,
|
| + uLong offset,
|
| + int origin);
|
| +
|
| +} // compressor_archive_functions
|
|
|
| class CompressorArchiveLibarchive : public CompressorArchive {
|
| public:
|
| @@ -26,36 +46,48 @@ class CompressorArchiveLibarchive : public CompressorArchive {
|
| virtual ~CompressorArchiveLibarchive();
|
|
|
| // Creates an archive object.
|
| - virtual void CreateArchive();
|
| + virtual bool CreateArchive();
|
|
|
| // Releases all resources obtained by libarchive.
|
| - virtual void CloseArchive(bool has_error);
|
| + virtual bool CloseArchive(bool has_error);
|
|
|
| // Adds an entry to the archive.
|
| - virtual void AddToArchive(const std::string& filename,
|
| + virtual bool AddToArchive(const std::string& filename,
|
| int64_t file_size,
|
| - time_t modification_time,
|
| + int64_t modification_time,
|
| bool is_directory);
|
|
|
| - // A getter function for archive_.
|
| - struct archive* archive() const { return archive_; }
|
| + // A getter function for zip_file_.
|
| + zipFile zip_file() const { return zip_file_; }
|
|
|
| // A getter function for compressor_stream.
|
| CompressorStream* compressor_stream() const { return compressor_stream_; }
|
|
|
| + // Custom functions need to access private variables of
|
| + // CompressorArchiveLibarchive frequently.
|
| + friend uLong compressor_archive_functions::CustomArchiveWrite(
|
| + void* compressor, void* stream, const void* buffer, uLong length);
|
| +
|
| + friend long compressor_archive_functions::CustomArchiveTell(
|
| + void* compressor, void* stream);
|
| +
|
| + friend long compressor_archive_functions::CustomArchiveSeek(
|
| + void* compressor, void* stream, uLong offset, int origin);
|
| +
|
| private:
|
| // An instance that takes care of all IO operations.
|
| CompressorStream* compressor_stream_;
|
|
|
| - // The libarchive correspondent archive object.
|
| - struct archive* archive_;
|
| -
|
| - // The libarchive correspondent archive entry object that is currently
|
| - // processed.
|
| - struct archive_entry* entry;
|
| + // The minizip correspondent archive object.
|
| + zipFile zip_file_;
|
|
|
| // The buffer used to store the data read from JavaScript.
|
| char* destination_buffer_;
|
| +
|
| + // The current offset of the zip archive file.
|
| + int64_t offset_;
|
| + // The size of the zip archive file.
|
| + int64_t length_;
|
| };
|
|
|
| #endif // COMPRESSOR_ARCHIVE_LIBARCHIVE_H_
|
|
|