-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathzipmerge.h
More file actions
37 lines (28 loc) · 1.28 KB
/
zipmerge.h
File metadata and controls
37 lines (28 loc) · 1.28 KB
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
#pragma once
#include <cstdlib>
#include <cstdint>
#include <string_view>
struct output_cd_t {
uint8_t* bytes;
uint32_t length;
uint32_t capacity;
};
inline output_cd_t output_cd{}; // An in-memory buffer in which the central-directory records for
// the output file are accumulated.
// Read and write little-endian integers (as the only supported host platforms are little-endian,
// and all host platforms support unaligned memory accesses, these macros are currently very
// simple).
#define read2(ptr) (*(uint16_t*)(ptr))
#define read4(ptr) (*(uint32_t*)(ptr))
#define write2(ptr, val) (*(uint16_t*)(ptr) = (val))
#define write4(ptr, val) (*(uint32_t*)(ptr) = (val))
// Add the bytes [src, src + len) to the output's central-directory.
void append_cd(const uint8_t* src, uint32_t len);
// Test whether a given filename should be included in the output zip.
// Note that if a call returns true for a given filename, all future calls with the same filename
// will return false.
bool should_include_filename_now(const uint8_t* name, uint32_t len);
inline constexpr std::string_view eocd_signature = "\x50\x4b\x05\x06";
const uint8_t* find_eocd(const uint8_t* input_file, size_t input_file_len);
int zipmerge_main(int argc, const char** argv);
void reset();