forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tar.d.ts
230 lines (204 loc) · 5.87 KB
/
tar.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
// Type definitions for tar v1.0.1
// Project: https://github.com/npm/node-tar
// Definitions by: Maxime LUCE <https://github.com/SomaticIT>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// TODO: When/if typings for [fstream](https://github.com/npm/fstream) are written, refactor this typing to use it for the various streams.
/// <reference path="../node/node.d.ts" />
declare module "tar" {
import stream = require("stream");
// #region Interfaces
export interface HeaderProperties {
path?: string;
mode?: number;
uid?: number;
gid?: number;
size?: number;
mtime?: number;
uname?: string;
gname?: string;
devmaj?: number;
devmin?: number;
}
export interface ExtractOptions {
type?: string;
Directory?: boolean;
path?: string;
strip?: number;
}
export interface ParseStream extends NodeJS.ReadWriteStream {
position: number;
_stream: stream.Stream;
_ended: boolean;
_streamEnd(): void;
_process(c: Buffer): void;
_startEntry(c: Buffer): void;
}
export interface PackStream extends NodeJS.ReadWriteStream {
writable: boolean;
readable: boolean;
_noProprietary: boolean;
_global: HeaderProperties;
_buffer: stream.Stream[];
_currentEntry: any;
_processing: boolean;
_pipeRoot: stream.Stream;
_needDrain: boolean;
_paused: boolean;
addGlobal(props: HeaderProperties): void;
add(stream: stream.Stream): boolean;
destroy(): void;
_process(): void;
}
export interface ExtractStream extends ParseStream {
}
// #endregion
// #region Enums
export var fields: {
path: number;
mode: number;
uid: number;
gid: number;
size: number;
mtime: number;
cksum: number;
type: number;
linkpath: number;
ustar: number;
ustarvar: number;
uname: number;
gname: number;
devmaj: number;
devmin: number;
prefix: number;
fill: number;
};
export var fieldSize: number[];
export var fieldOffs: number[];
export var fieldEnds: number[];
/**
* Different values of the 'type' field
* paths match the values of Stats.isX() functions, where appropriate
*/
export var types: {
0: string;
"\0": string;
"": string;
1: string;
2: string;
3: string;
4: string;
5: string;
6: string;
7: string;
g: string;
x: string;
A: string;
D: string;
I: string;
K: string;
L: string;
M: string;
N: string;
S: string;
V: string;
X: string;
File: string;
OldFile: string;
Link: string;
SymbolicLick: string;
CharacterDevice: string;
BlockDevice: string;
Directory: string;
FIFO: string;
ContiguousFile: string;
GlobalExtendedHeader: string;
ExtendedHeader: string;
SolarisACL: string;
GNUDumpDir: string;
INode: string;
NextFileHasLonLinkPath: string;
NextFileHasLongPath: string;
ContinuationFile: string;
TapeVolumeHeader: string;
OldExtendedHeader: string;
};
/**
* Values for the mode field
*/
export var modes: {
suid: number;
sgid: number;
svtx: number;
uread: number;
uwrite: number;
uexec: number;
gread: number;
gwrite: number;
gexec: number;
oread: number;
owrite: number;
oexec: number;
};
export var numeric: {
mode: boolean;
uid: boolean;
gid: boolean;
size: boolean;
mtime: boolean;
devmaj: boolean;
devmin: boolean;
cksum: boolean;
atime: boolean;
ctime: boolean;
dev: boolean;
ino: boolean;
nlink: boolean;
};
export var knownExtended: {
atime: boolean;
charset: boolean;
comment: boolean;
ctime: boolean;
gid: boolean;
gname: boolean;
linkpat: boolean;
mtime: boolean;
path: boolean;
realtime: boolean;
security: boolean;
size: boolean;
uid: boolean;
uname: boolean;
};
export var headerSize: number;
export var blockSize: number;
//#endregion
//#region Global Methods
/**
* Returns a writable stream. Write tar data to it and it will emit entry events for each entry parsed from the tarball. This is used by tar.Extract.
*/
export function Parse(): ParseStream;
/**
* Returns a through stream. Use fstream to write files into the pack stream and you will receive tar archive data from the pack stream.
* This only works with directories, it does not work with individual files.
* The optional properties object are used to set properties in the tar 'Global Extended Header'.
*/
export function Pack(props?: HeaderProperties): PackStream;
/**
* Returns a through stream. Write tar data to the stream and the files in the tarball will be extracted onto the filesystem.
*/
export function Extract(path: string): ExtractStream;
/**
* Returns a through stream. Write tar data to the stream and the files in the tarball will be extracted onto the filesystem.
* options can be:
* ```
* {
* path: '/path/to/extract/tar/into',
* strip: 0, // how many path segments to strip from the root when extracting
* }
* ```
* options also get passed to the fstream.Writer instance that tar uses internally.
*/
export function Extract(opts: ExtractOptions): ExtractStream;
//#endregion
}