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

Side by Side Diff: ui/file_manager/zip_archiver/cpp/compressor_archive_libarchive.h

Issue 2818673004: Rename filenames that end with libarchive with minizip. (Closed)
Patch Set: Created 3 years, 8 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
(Empty)
1 // Copyright 2017 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPRESSOR_ARCHIVE_MINIZIP_H_
6 #define COMPRESSOR_ARCHIVE_MINIZIP_H_
7
8 #include <string>
9
10 #include "third_party/zlib/contrib/minizip/unzip.h"
11 #include "third_party/zlib/contrib/minizip/zip.h"
12
13 #include "compressor_archive.h"
14 #include "compressor_stream.h"
15
16 // A namespace with constants used by CompressorArchiveMinizip.
17 namespace compressor_archive_constants {
18
19 const char kCreateArchiveError[] = "Failed to create archive.";
20 const char kAddToArchiveError[] = "Failed to add entry to archive.";
21 const char kCloseArchiveError[] = "Failed to close archive.";
22
23 }
24
25 // A name space with custom functions passed to minizip.
26 namespace compressor_archive_functions {
27
28 uLong CustomArchiveWrite(void* compressor,
29 void* stream,
30 const void* buffer,
31 uLong length);
32
33 long CustomArchiveTell(void* compressor, void* stream);
34
35 long CustomArchiveSeek(void* compressor,
36 void* stream,
37 uLong offset,
38 int origin);
39
40 } // compressor_archive_functions
41
42 class CompressorArchiveMinizip : public CompressorArchive {
43 public:
44 explicit CompressorArchiveMinizip(CompressorStream* compressor_stream);
45
46 virtual ~CompressorArchiveMinizip();
47
48 // Creates an archive object.
49 virtual bool CreateArchive();
50
51 // Releases all resources obtained by minizip.
52 virtual bool CloseArchive(bool has_error);
53
54 // Adds an entry to the archive.
55 virtual bool AddToArchive(const std::string& filename,
56 int64_t file_size,
57 int64_t modification_time,
58 bool is_directory);
59
60 // A getter function for zip_file_.
61 zipFile zip_file() const { return zip_file_; }
62
63 // A getter function for compressor_stream.
64 CompressorStream* compressor_stream() const { return compressor_stream_; }
65
66 // Custom functions need to access private variables of
67 // CompressorArchiveMinizip frequently.
68 friend uLong compressor_archive_functions::CustomArchiveWrite(
69 void* compressor, void* stream, const void* buffer, uLong length);
70
71 friend long compressor_archive_functions::CustomArchiveTell(
72 void* compressor, void* stream);
73
74 friend long compressor_archive_functions::CustomArchiveSeek(
75 void* compressor, void* stream, uLong offset, int origin);
76
77 private:
78 // An instance that takes care of all IO operations.
79 CompressorStream* compressor_stream_;
80
81 // The minizip correspondent archive object.
82 zipFile zip_file_;
83
84 // The buffer used to store the data read from JavaScript.
85 char* destination_buffer_;
86
87 // The current offset of the zip archive file.
88 int64_t offset_;
89 // The size of the zip archive file.
90 int64_t length_;
91 };
92
93 #endif // COMPRESSOR_ARCHIVE_MINIZIP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698