-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathcompressor_archive_libarchive.h
61 lines (44 loc) · 1.85 KB
/
compressor_archive_libarchive.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright 2017 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPRESSOR_ARCHIVE_LIBARCHIVE_H_
#define COMPRESSOR_ARCHIVE_LIBARCHIVE_H_
#include <string>
#include "archive.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
class CompressorArchiveLibarchive : public CompressorArchive {
public:
explicit CompressorArchiveLibarchive(CompressorStream* compressor_stream);
virtual ~CompressorArchiveLibarchive();
// Creates an archive object.
virtual void CreateArchive();
// Releases all resources obtained by libarchive.
virtual void CloseArchive(bool has_error);
// Adds an entry to the archive.
virtual void AddToArchive(const std::string& filename,
int64_t file_size,
time_t modification_time,
bool is_directory);
// A getter function for archive_.
struct archive* archive() const { return archive_; }
// A getter function for compressor_stream.
CompressorStream* compressor_stream() const { return compressor_stream_; }
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 buffer used to store the data read from JavaScript.
char* destination_buffer_;
};
#endif // COMPRESSOR_ARCHIVE_LIBARCHIVE_H_