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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
use std::io;
use zerocopy::LE;
use crate::{read::ReadBytesExt, version::InnoVersion};
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub struct EntryCounts {
language: u32,
custom_message: u32,
permission: u32,
r#type: u32,
component: u32,
task: u32,
directory: u32,
is_sig_key: u32,
file: u32,
file_location: u32,
icon: u32,
ini: u32,
registry: u32,
install_delete: u32,
uninstall_delete: u32,
run: u32,
uninstall_run: u32,
}
impl EntryCounts {
pub fn read<R>(mut reader: R, version: InnoVersion) -> io::Result<Self>
where
R: io::Read,
{
let mut counts = Self::default();
if version >= 4 {
counts.language = reader.read_u32::<LE>()?;
} else if version >= (2, 0, 1) {
counts.language = 1;
}
if version >= (4, 2, 1) {
counts.custom_message = reader.read_u32::<LE>()?;
}
if version >= 4.1 {
counts.permission = reader.read_u32::<LE>()?;
}
if version >= 2 || version.is_isx() {
counts.r#type = reader.read_u32::<LE>()?;
counts.component = reader.read_u32::<LE>()?;
}
if version >= 2 || (version.is_isx() && version >= (1, 3, 17)) {
counts.task = reader.read_u32::<LE>()?;
}
counts.directory = reader.read_u32::<LE>()?;
if version >= 6.5 {
counts.is_sig_key = reader.read_u32::<LE>()?;
}
counts.file = reader.read_u32::<LE>()?;
counts.file_location = reader.read_u32::<LE>()?;
counts.icon = reader.read_u32::<LE>()?;
counts.ini = reader.read_u32::<LE>()?;
counts.registry = reader.read_u32::<LE>()?;
counts.install_delete = reader.read_u32::<LE>()?;
counts.uninstall_delete = reader.read_u32::<LE>()?;
counts.run = reader.read_u32::<LE>()?;
counts.uninstall_run = reader.read_u32::<LE>()?;
Ok(counts)
}
/// Returns the number of [Language] entries.
///
/// [Language]: crate::entry::Language
#[must_use]
#[inline]
pub const fn language(&self) -> u32 {
self.language
}
/// Returns the number of [Custom Message] entries.
///
/// [Custom Message]: crate::entry::MessageEntry
#[must_use]
#[inline]
pub const fn custom_message(&self) -> u32 {
self.custom_message
}
/// Returns the number of [Permission] entries.
///
/// [Permission]: crate::entry::Permission
#[must_use]
#[inline]
pub const fn permission(&self) -> u32 {
self.permission
}
/// Returns the number of [Type] entries.
///
/// [Type]: crate::entry::Type
#[must_use]
#[inline]
pub const fn r#type(&self) -> u32 {
self.r#type
}
/// Returns the number of [Component] entries.
///
/// [Component]: crate::entry::Component
#[must_use]
#[inline]
pub const fn component(&self) -> u32 {
self.component
}
/// Returns the number of [Task] entries.
///
/// [Task]: crate::entry::Task
#[must_use]
#[inline]
pub const fn task(&self) -> u32 {
self.task
}
/// Returns the number of [Directory] entries.
///
/// [Directory]: crate::entry::Directory
#[must_use]
#[inline]
pub const fn directory(&self) -> u32 {
self.directory
}
/// Returns the number of [IS Sig Key] entries.
///
/// [ISSigKey]: crate::entry::ISSigKey
#[must_use]
#[inline]
pub const fn is_sig_key(&self) -> u32 {
self.is_sig_key
}
/// Returns the number of [File] entries.
///
/// [File]: crate::entry::File
#[must_use]
#[inline]
pub const fn file(&self) -> u32 {
self.file
}
/// Returns the number of [File Location] entries.
///
/// [File Location]: crate::entry::FileLocation
#[must_use]
#[inline]
pub const fn file_location(&self) -> u32 {
self.file_location
}
/// Returns the number of [Icon] entries.
///
/// [Icon]: crate::entry::Icon
#[must_use]
#[inline]
pub const fn icon(&self) -> u32 {
self.icon
}
/// Returns the number of [Ini] entries.
///
/// [Ini]: crate::entry::Ini
#[must_use]
#[inline]
pub const fn ini(&self) -> u32 {
self.ini
}
/// Returns the number of [Registry] entries.
///
/// [Registry]: crate::entry::RegistryEntry
#[must_use]
#[inline]
pub const fn registry(&self) -> u32 {
self.registry
}
/// Returns the number of [Install Delete] entries.
///
/// [Install Delete]: crate::entry::DeleteEntry
#[must_use]
#[inline]
pub const fn install_delete(&self) -> u32 {
self.install_delete
}
/// Returns the number of [Uninstall Delete] entries.
///
/// [Uninstall Delete]: crate::entry::DeleteEntry
#[must_use]
#[inline]
pub const fn uninstall_delete(&self) -> u32 {
self.uninstall_delete
}
/// Returns the number of [Run] entries.
///
/// [Run]: crate::entry::RunEntry
#[must_use]
#[inline]
pub const fn run(&self) -> u32 {
self.run
}
/// Returns the number of [Uninstall Run] entries.
///
/// [Uninstall Run]: crate::entry::RunEntry
#[must_use]
#[inline]
pub const fn uninstall_run(&self) -> u32 {
self.uninstall_run
}
}