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

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

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

Powered by Google App Engine
This is Rietveld 408576698