generated from napi-rs/package-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.d.ts
424 lines (418 loc) · 14.2 KB
/
index.d.ts
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
/* auto-generated by NAPI-RS */
/* eslint-disable */
export declare class Archive {
/** Create a new archive with the underlying path. */
constructor(input: string | Buffer)
entries(): Entries
/**
* Unpacks the contents tarball into the specified `dst`.
*
* This function will iterate over the entire contents of this tarball,
* extracting each file in turn to the location specified by the entry's
* path name.
*
* This operation is relatively sensitive in that it will not write files
* outside of the path specified by `dst`. Files in the archive which have
* a '..' in their path are skipped during the unpacking process.
*/
unpack(to: string): void
/**
* Set the mask of the permission bits when unpacking this entry.
*
* The mask will be inverted when applying against a mode, similar to how
* `umask` works on Unix. In logical notation it looks like:
*
* ```text
* new_mode = old_mode & (~mask)
* ```
*
* The mask is 0 by default and is currently only implemented on Unix.
*/
setMask(mask: number): void
/**
* Indicate whether extended file attributes (xattrs on Unix) are preserved
* when unpacking this archive.
*
* This flag is disabled by default and is currently only implemented on
* Unix using xattr support. This may eventually be implemented for
* Windows, however, if other archive implementations are found which do
* this as well.
*/
setUnpackXattrs(unpackXattrs: boolean): void
/**
* Indicate whether extended permissions (like suid on Unix) are preserved
* when unpacking this entry.
*
* This flag is disabled by default and is currently only implemented on
* Unix.
*/
setPreservePermissions(preservePermissions: boolean): void
/**
* Indicate whether numeric ownership ids (like uid and gid on Unix)
* are preserved when unpacking this entry.
*
* This flag is disabled by default and is currently only implemented on
* Unix.
*/
setPreserveOwnerships(preserveOwnerships: boolean): void
/** Indicate whether files and symlinks should be overwritten on extraction. */
setOverwrite(overwrite: boolean): void
/**
* Indicate whether access time information is preserved when unpacking
* this entry.
*
* This flag is enabled by default.
*/
setPreserveMtime(preserveMtime: boolean): void
/**
* Ignore zeroed headers, which would otherwise indicate to the archive that it has no more
* entries.
*
* This can be used in case multiple tar archives have been concatenated together.
*/
setIgnoreZeros(ignoreZeros: boolean): void
}
export declare class Entries {
[Symbol.iterator](): Iterator<Entry, void, void>
}
export declare class Entry {
/**
* Returns the path name for this entry.
*
* This method may fail if the pathname is not valid Unicode and this is
* called on a Windows platform.
*
* Note that this function will convert any `\` characters to directory
* separators, and it will not always return the same value as
* `self.header().path()` as some archive formats have support for longer
* path names described in separate entries.
*
* It is recommended to use this method instead of inspecting the `header`
* directly to ensure that various archive formats are handled correctly.
*/
path(): string | null
header(): ReadonlyHeader
}
export declare class Header {
/** Returns a view into this header as a byte array. */
asBytes(): Buffer
/**
* Returns the size of entry's data this header represents.
*
* This is different from `Header::size` for sparse files, which have
* some longer `size()` but shorter `entry_size()`. The `entry_size()`
* listed here should be the number of bytes in the archive this header
* describes.
*
* May return an error if the field is corrupted.
*/
entrySize(): bigint
/**
* Returns the file size this header represents.
*
* May return an error if the field is corrupted.
*/
size(): bigint
/** Encodes the `size` argument into the size field of this header. */
setSize(size: number | bigint): void
/**
* Returns the raw path name stored in this header.
*
* This method may fail if the pathname is not valid Unicode and this is
* called on a Windows platform.
*
* Note that this function will convert any `\` characters to directory
* separators.
*/
path(): string
/**
* Sets the path name for this header.
*
* This function will set the pathname listed in this header, encoding it
* in the appropriate format. May fail if the path is too long or if the
* path specified is not Unicode and this is a Windows platform. Will
* strip out any "." path component, which signifies the current directory.
*
* Note: This function does not support names over 100 bytes, or paths
* over 255 bytes, even for formats that support longer names. Instead,
* use `Builder` methods to insert a long-name extension at the same time
* as the file content.
*/
setPath(path: string): void
/**
* Returns the link name stored in this header as a byte array, if any.
*
* This function is guaranteed to succeed, but you may wish to call the
* `link_name` method to convert to a `Path`.
*
* Note that this function will convert any `\` characters to directory
* separators.
*/
linkName(): string | null
/**
* Sets the link name for this header.
*
* This function will set the linkname listed in this header, encoding it
* in the appropriate format. May fail if the link name is too long or if
* the path specified is not Unicode and this is a Windows platform. Will
* strip out any "." path component, which signifies the current directory.
*
* To use GNU long link names, prefer instead [`crate::Builder::append_link`].
*/
setLinkName(linkName: string): void
/**
* Sets the link name for this header without any transformation.
*
* This function is like [`Self::set_link_name`] but accepts an arbitrary byte array.
* Hence it will not perform any canonicalization, such as replacing duplicate `//` with `/`.
*/
setLinkNameLiteral(linkName: string): void
/**
* Returns the mode bits for this file
*
* May return an error if the field is corrupted.
*/
mode(): number
/** Encodes the `mode` provided into this header. */
setMode(mode: number): void
/**
* Returns the value of the owner's user ID field
*
* May return an error if the field is corrupted.
*/
uid(): bigint
/** Encodes the `uid` provided into this header. */
setUid(uid: bigint): void
/** Returns the value of the group's user ID field */
gid(): bigint
/** Encodes the `gid` provided into this header. */
setGid(gid: bigint): void
/** Returns the last modification time in Unix time format */
mtime(): bigint
/**
* Encodes the `mtime` provided into this header.
*
* Note that this time is typically a number of seconds passed since
* January 1, 1970.
*/
setTime(mtime: bigint): void
/**
* Return the user name of the owner of this file.
*
* A return value of `Ok(Some(..))` indicates that the user name was
* present and was valid utf-8, `Ok(None)` indicates that the user name is
* not present in this archive format, and `Err` indicates that the user
* name was present but was not valid utf-8.
*/
username(): string | null
/**
* Sets the username inside this header.
*
* This function will return an error if this header format cannot encode a
* user name or the name is too long.
*/
setUsername(username: string): void
/**
* Return the group name of the owner of this file.
*
* A return value of `Ok(Some(..))` indicates that the group name was
* present and was valid utf-8, `Ok(None)` indicates that the group name is
* not present in this archive format, and `Err` indicates that the group
* name was present but was not valid utf-8.
*/
groupname(): string | null
/**
* Sets the group name inside this header.
*
* This function will return an error if this header format cannot encode a
* group name or the name is too long.
*/
setGroupname(groupname: string): void
/**
* Returns the device major number, if present.
*
* This field may not be present in all archives, and it may not be
* correctly formed in all archives. `Ok(Some(..))` means it was present
* and correctly decoded, `Ok(None)` indicates that this header format does
* not include the device major number, and `Err` indicates that it was
* present and failed to decode.
*/
deviceMajor(): number | null
/**
* Encodes the value `major` into the dev_major field of this header.
*
* This function will return an error if this header format cannot encode a
* major device number.
*/
setDeviceMajor(deviceMajor: number): void
/**
* Returns the device minor number, if present.
*
* This field may not be present in all archives, and it may not be
* correctly formed in all archives. `Ok(Some(..))` means it was present
* and correctly decoded, `Ok(None)` indicates that this header format does
* not include the device minor number, and `Err` indicates that it was
* present and failed to decode.
*/
deviceMinor(): number | null
/**
* Encodes the value `minor` into the dev_minor field of this header.
*
* This function will return an error if this header format cannot encode a
* minor device number.
*/
setDeviceMinor(deviceMinor: number): void
/** Returns the type of file described by this header. */
entryType(): EntryType
/** Sets the type of file that will be described by this header. */
setEntryType(entryType: EntryType): void
/**
* Returns the checksum field of this header.
*
* May return an error if the field is corrupted.
*/
cksum(): number
/**
* Sets the checksum field of this header based on the current fields in
* this header.
*/
setCksum(): void
}
export declare class ReadonlyHeader {
/** Returns a view into this header as a byte array. */
asBytes(): Buffer
/**
* Returns the size of entry's data this header represents.
*
* This is different from `Header::size` for sparse files, which have
* some longer `size()` but shorter `entry_size()`. The `entry_size()`
* listed here should be the number of bytes in the archive this header
* describes.
*
* May return an error if the field is corrupted.
*/
entrySize(): bigint
/**
* Returns the file size this header represents.
*
* May return an error if the field is corrupted.
*/
size(): bigint
/**
* Returns the raw path name stored in this header.
*
* This method may fail if the pathname is not valid Unicode and this is
* called on a Windows platform.
*
* Note that this function will convert any `\` characters to directory
* separators.
*/
path(): string
/**
* Returns the link name stored in this header as a byte array, if any.
*
* This function is guaranteed to succeed, but you may wish to call the
* `link_name` method to convert to a `Path`.
*
* Note that this function will convert any `\` characters to directory
* separators.
*/
linkName(): string | null
/**
* Returns the mode bits for this file
*
* May return an error if the field is corrupted.
*/
mode(): number
/**
* Returns the value of the owner's user ID field
*
* May return an error if the field is corrupted.
*/
uid(): bigint
/** Returns the value of the group's user ID field */
gid(): bigint
/** Returns the last modification time in Unix time format */
mtime(): bigint
/**
* Return the user name of the owner of this file.
*
* A return value of `Ok(Some(..))` indicates that the user name was
* present and was valid utf-8, `Ok(None)` indicates that the user name is
* not present in this archive format, and `Err` indicates that the user
* name was present but was not valid utf-8.
*/
username(): string | null
/**
* Return the group name of the owner of this file.
*
* A return value of `Ok(Some(..))` indicates that the group name was
* present and was valid utf-8, `Ok(None)` indicates that the group name is
* not present in this archive format, and `Err` indicates that the group
* name was present but was not valid utf-8.
*/
groupname(): string | null
/**
* Returns the device major number, if present.
*
* This field may not be present in all archives, and it may not be
* correctly formed in all archives. `Ok(Some(..))` means it was present
* and correctly decoded, `Ok(None)` indicates that this header format does
* not include the device major number, and `Err` indicates that it was
* present and failed to decode.
*/
deviceMajor(): number | null
/**
* Returns the device minor number, if present.
*
* This field may not be present in all archives, and it may not be
* correctly formed in all archives. `Ok(Some(..))` means it was present
* and correctly decoded, `Ok(None)` indicates that this header format does
* not include the device minor number, and `Err` indicates that it was
* present and failed to decode.
*/
deviceMinor(): number | null
/** Returns the type of file described by this header. */
entryType(): EntryType
/**
* Returns the checksum field of this header.
*
* May return an error if the field is corrupted.
*/
cksum(): number
}
/**
* Indicate for the type of file described by a header.
*
* Each `Header` has an `entry_type` method returning an instance of this type
* which can be used to inspect what the header is describing.
* A non-exhaustive enum representing the possible entry types
*/
export declare const enum EntryType {
/** Regular file */
Regular = 0,
/** Hard link */
Link = 1,
/** Symbolic link */
Symlink = 2,
/** Character device */
Char = 3,
/** Block device */
Block = 4,
/** Directory */
Directory = 5,
/** Named pipe (fifo) */
Fifo = 6,
/** Implementation-defined 'high-performance' type, treated as regular file */
Continuous = 7,
/** GNU extension - long file name */
GNULongName = 8,
/** GNU extension - long link name (link target) */
GNULongLink = 9,
/** GNU extension - sparse file */
GNUSparse = 10,
/** Global extended header */
XGlobalHeader = 11,
/** Extended Header */
XHeader = 12
}