tar 6.2.1 → 7.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (253) hide show
  1. package/README.md +30 -16
  2. package/dist/commonjs/create.d.ts +8 -0
  3. package/dist/commonjs/create.d.ts.map +1 -0
  4. package/dist/commonjs/create.js +106 -0
  5. package/dist/commonjs/create.js.map +1 -0
  6. package/dist/commonjs/cwd-error.d.ts +8 -0
  7. package/dist/commonjs/cwd-error.d.ts.map +1 -0
  8. package/dist/commonjs/cwd-error.js +18 -0
  9. package/dist/commonjs/cwd-error.js.map +1 -0
  10. package/dist/commonjs/extract.d.ts +8 -0
  11. package/dist/commonjs/extract.d.ts.map +1 -0
  12. package/dist/commonjs/extract.js +141 -0
  13. package/dist/commonjs/extract.js.map +1 -0
  14. package/dist/commonjs/get-write-flag.d.ts +2 -0
  15. package/dist/commonjs/get-write-flag.d.ts.map +1 -0
  16. package/dist/commonjs/get-write-flag.js +29 -0
  17. package/dist/commonjs/get-write-flag.js.map +1 -0
  18. package/dist/commonjs/header.d.ts +54 -0
  19. package/dist/commonjs/header.d.ts.map +1 -0
  20. package/dist/commonjs/header.js +311 -0
  21. package/dist/commonjs/header.js.map +1 -0
  22. package/dist/commonjs/index.d.ts +19 -0
  23. package/dist/commonjs/index.d.ts.map +1 -0
  24. package/dist/commonjs/index.js +54 -0
  25. package/dist/commonjs/index.js.map +1 -0
  26. package/dist/commonjs/large-numbers.d.ts +4 -0
  27. package/dist/commonjs/large-numbers.d.ts.map +1 -0
  28. package/dist/commonjs/large-numbers.js +99 -0
  29. package/dist/commonjs/large-numbers.js.map +1 -0
  30. package/dist/commonjs/list.d.ts +8 -0
  31. package/dist/commonjs/list.d.ts.map +1 -0
  32. package/dist/commonjs/list.js +167 -0
  33. package/dist/commonjs/list.js.map +1 -0
  34. package/dist/commonjs/mkdir.d.ts +27 -0
  35. package/dist/commonjs/mkdir.d.ts.map +1 -0
  36. package/dist/commonjs/mkdir.js +209 -0
  37. package/dist/commonjs/mkdir.js.map +1 -0
  38. package/dist/commonjs/mode-fix.d.ts +2 -0
  39. package/dist/commonjs/mode-fix.d.ts.map +1 -0
  40. package/dist/commonjs/mode-fix.js +29 -0
  41. package/dist/commonjs/mode-fix.js.map +1 -0
  42. package/dist/commonjs/normalize-unicode.d.ts +2 -0
  43. package/dist/commonjs/normalize-unicode.d.ts.map +1 -0
  44. package/dist/commonjs/normalize-unicode.js +17 -0
  45. package/dist/commonjs/normalize-unicode.js.map +1 -0
  46. package/dist/commonjs/normalize-windows-path.d.ts +2 -0
  47. package/dist/commonjs/normalize-windows-path.d.ts.map +1 -0
  48. package/dist/commonjs/normalize-windows-path.js +12 -0
  49. package/dist/commonjs/normalize-windows-path.js.map +1 -0
  50. package/dist/commonjs/options.d.ts +545 -0
  51. package/dist/commonjs/options.d.ts.map +1 -0
  52. package/dist/commonjs/options.js +55 -0
  53. package/dist/commonjs/options.js.map +1 -0
  54. package/dist/commonjs/pack.d.ts +98 -0
  55. package/dist/commonjs/pack.d.ts.map +1 -0
  56. package/dist/commonjs/pack.js +461 -0
  57. package/dist/commonjs/pack.js.map +1 -0
  58. package/dist/commonjs/package.json +3 -0
  59. package/dist/commonjs/parse.d.ts +84 -0
  60. package/dist/commonjs/parse.d.ts.map +1 -0
  61. package/dist/commonjs/parse.js +571 -0
  62. package/dist/commonjs/parse.js.map +1 -0
  63. package/dist/commonjs/path-reservations.d.ts +11 -0
  64. package/dist/commonjs/path-reservations.d.ts.map +1 -0
  65. package/dist/commonjs/path-reservations.js +169 -0
  66. package/dist/commonjs/path-reservations.js.map +1 -0
  67. package/dist/commonjs/pax.d.ts +27 -0
  68. package/dist/commonjs/pax.d.ts.map +1 -0
  69. package/dist/commonjs/pax.js +158 -0
  70. package/dist/commonjs/pax.js.map +1 -0
  71. package/dist/commonjs/read-entry.d.ts +37 -0
  72. package/dist/commonjs/read-entry.d.ts.map +1 -0
  73. package/dist/commonjs/read-entry.js +139 -0
  74. package/dist/commonjs/read-entry.js.map +1 -0
  75. package/dist/commonjs/replace.d.ts +5 -0
  76. package/dist/commonjs/replace.d.ts.map +1 -0
  77. package/dist/commonjs/replace.js +223 -0
  78. package/dist/commonjs/replace.js.map +1 -0
  79. package/dist/commonjs/strip-absolute-path.d.ts +2 -0
  80. package/dist/commonjs/strip-absolute-path.d.ts.map +1 -0
  81. package/dist/commonjs/strip-absolute-path.js +29 -0
  82. package/dist/commonjs/strip-absolute-path.js.map +1 -0
  83. package/dist/commonjs/strip-trailing-slashes.d.ts +2 -0
  84. package/dist/commonjs/strip-trailing-slashes.d.ts.map +1 -0
  85. package/dist/commonjs/strip-trailing-slashes.js +18 -0
  86. package/dist/commonjs/strip-trailing-slashes.js.map +1 -0
  87. package/dist/commonjs/symlink-error.d.ts +9 -0
  88. package/dist/commonjs/symlink-error.d.ts.map +1 -0
  89. package/dist/commonjs/symlink-error.js +19 -0
  90. package/dist/commonjs/symlink-error.js.map +1 -0
  91. package/dist/commonjs/types.d.ts +7 -0
  92. package/dist/commonjs/types.d.ts.map +1 -0
  93. package/dist/commonjs/types.js +50 -0
  94. package/dist/commonjs/types.js.map +1 -0
  95. package/dist/commonjs/unpack.d.ts +98 -0
  96. package/dist/commonjs/unpack.d.ts.map +1 -0
  97. package/dist/commonjs/unpack.js +921 -0
  98. package/dist/commonjs/unpack.js.map +1 -0
  99. package/dist/commonjs/update.d.ts +3 -0
  100. package/dist/commonjs/update.d.ts.map +1 -0
  101. package/dist/commonjs/update.js +47 -0
  102. package/dist/commonjs/update.js.map +1 -0
  103. package/dist/commonjs/warn-method.d.ts +20 -0
  104. package/dist/commonjs/warn-method.d.ts.map +1 -0
  105. package/dist/commonjs/warn-method.js +31 -0
  106. package/dist/commonjs/warn-method.js.map +1 -0
  107. package/dist/commonjs/winchars.d.ts +3 -0
  108. package/dist/commonjs/winchars.d.ts.map +1 -0
  109. package/dist/commonjs/winchars.js +14 -0
  110. package/dist/commonjs/winchars.js.map +1 -0
  111. package/dist/commonjs/write-entry.d.ts +125 -0
  112. package/dist/commonjs/write-entry.d.ts.map +1 -0
  113. package/dist/commonjs/write-entry.js +657 -0
  114. package/dist/commonjs/write-entry.js.map +1 -0
  115. package/dist/esm/create.d.ts +8 -0
  116. package/dist/esm/create.d.ts.map +1 -0
  117. package/dist/esm/create.js +99 -0
  118. package/dist/esm/create.js.map +1 -0
  119. package/dist/esm/cwd-error.d.ts +8 -0
  120. package/dist/esm/cwd-error.d.ts.map +1 -0
  121. package/dist/esm/cwd-error.js +14 -0
  122. package/dist/esm/cwd-error.js.map +1 -0
  123. package/dist/esm/extract.d.ts +8 -0
  124. package/dist/esm/extract.d.ts.map +1 -0
  125. package/dist/esm/extract.js +111 -0
  126. package/dist/esm/extract.js.map +1 -0
  127. package/dist/esm/get-write-flag.d.ts +2 -0
  128. package/dist/esm/get-write-flag.d.ts.map +1 -0
  129. package/dist/esm/get-write-flag.js +23 -0
  130. package/dist/esm/get-write-flag.js.map +1 -0
  131. package/dist/esm/header.d.ts +54 -0
  132. package/dist/esm/header.d.ts.map +1 -0
  133. package/dist/esm/header.js +284 -0
  134. package/dist/esm/header.js.map +1 -0
  135. package/dist/esm/index.d.ts +19 -0
  136. package/dist/esm/index.d.ts.map +1 -0
  137. package/dist/esm/index.js +20 -0
  138. package/dist/esm/index.js.map +1 -0
  139. package/dist/esm/large-numbers.d.ts +4 -0
  140. package/dist/esm/large-numbers.d.ts.map +1 -0
  141. package/dist/esm/large-numbers.js +94 -0
  142. package/dist/esm/large-numbers.js.map +1 -0
  143. package/dist/esm/list.d.ts +8 -0
  144. package/dist/esm/list.d.ts.map +1 -0
  145. package/dist/esm/list.js +137 -0
  146. package/dist/esm/list.js.map +1 -0
  147. package/dist/esm/mkdir.d.ts +27 -0
  148. package/dist/esm/mkdir.d.ts.map +1 -0
  149. package/dist/esm/mkdir.js +201 -0
  150. package/dist/esm/mkdir.js.map +1 -0
  151. package/dist/esm/mode-fix.d.ts +2 -0
  152. package/dist/esm/mode-fix.d.ts.map +1 -0
  153. package/dist/esm/mode-fix.js +25 -0
  154. package/dist/esm/mode-fix.js.map +1 -0
  155. package/dist/esm/normalize-unicode.d.ts +2 -0
  156. package/dist/esm/normalize-unicode.d.ts.map +1 -0
  157. package/dist/esm/normalize-unicode.js +13 -0
  158. package/dist/esm/normalize-unicode.js.map +1 -0
  159. package/dist/esm/normalize-windows-path.d.ts +2 -0
  160. package/dist/esm/normalize-windows-path.d.ts.map +1 -0
  161. package/{lib → dist/esm}/normalize-windows-path.js +5 -4
  162. package/dist/esm/normalize-windows-path.js.map +1 -0
  163. package/dist/esm/options.d.ts +545 -0
  164. package/dist/esm/options.d.ts.map +1 -0
  165. package/dist/esm/options.js +48 -0
  166. package/dist/esm/options.js.map +1 -0
  167. package/dist/esm/pack.d.ts +98 -0
  168. package/dist/esm/pack.d.ts.map +1 -0
  169. package/dist/esm/pack.js +429 -0
  170. package/dist/esm/pack.js.map +1 -0
  171. package/dist/esm/package.json +3 -0
  172. package/dist/esm/parse.d.ts +84 -0
  173. package/dist/esm/parse.d.ts.map +1 -0
  174. package/dist/esm/parse.js +567 -0
  175. package/dist/esm/parse.js.map +1 -0
  176. package/dist/esm/path-reservations.d.ts +11 -0
  177. package/dist/esm/path-reservations.d.ts.map +1 -0
  178. package/dist/esm/path-reservations.js +165 -0
  179. package/dist/esm/path-reservations.js.map +1 -0
  180. package/dist/esm/pax.d.ts +27 -0
  181. package/dist/esm/pax.d.ts.map +1 -0
  182. package/dist/esm/pax.js +154 -0
  183. package/dist/esm/pax.js.map +1 -0
  184. package/dist/esm/read-entry.d.ts +37 -0
  185. package/dist/esm/read-entry.d.ts.map +1 -0
  186. package/dist/esm/read-entry.js +135 -0
  187. package/dist/esm/read-entry.js.map +1 -0
  188. package/dist/esm/replace.d.ts +5 -0
  189. package/dist/esm/replace.d.ts.map +1 -0
  190. package/dist/esm/replace.js +216 -0
  191. package/dist/esm/replace.js.map +1 -0
  192. package/dist/esm/strip-absolute-path.d.ts +2 -0
  193. package/dist/esm/strip-absolute-path.d.ts.map +1 -0
  194. package/dist/esm/strip-absolute-path.js +25 -0
  195. package/dist/esm/strip-absolute-path.js.map +1 -0
  196. package/dist/esm/strip-trailing-slashes.d.ts +2 -0
  197. package/dist/esm/strip-trailing-slashes.d.ts.map +1 -0
  198. package/dist/esm/strip-trailing-slashes.js +14 -0
  199. package/dist/esm/strip-trailing-slashes.js.map +1 -0
  200. package/dist/esm/symlink-error.d.ts +9 -0
  201. package/dist/esm/symlink-error.d.ts.map +1 -0
  202. package/dist/esm/symlink-error.js +15 -0
  203. package/dist/esm/symlink-error.js.map +1 -0
  204. package/dist/esm/types.d.ts +7 -0
  205. package/dist/esm/types.d.ts.map +1 -0
  206. package/dist/esm/types.js +45 -0
  207. package/dist/esm/types.js.map +1 -0
  208. package/dist/esm/unpack.d.ts +98 -0
  209. package/dist/esm/unpack.d.ts.map +1 -0
  210. package/dist/esm/unpack.js +890 -0
  211. package/dist/esm/unpack.js.map +1 -0
  212. package/dist/esm/update.d.ts +3 -0
  213. package/dist/esm/update.d.ts.map +1 -0
  214. package/dist/esm/update.js +43 -0
  215. package/dist/esm/update.js.map +1 -0
  216. package/dist/esm/warn-method.d.ts +20 -0
  217. package/dist/esm/warn-method.d.ts.map +1 -0
  218. package/dist/esm/warn-method.js +27 -0
  219. package/dist/esm/warn-method.js.map +1 -0
  220. package/dist/esm/winchars.d.ts +3 -0
  221. package/dist/esm/winchars.d.ts.map +1 -0
  222. package/dist/esm/winchars.js +9 -0
  223. package/dist/esm/winchars.js.map +1 -0
  224. package/dist/esm/write-entry.d.ts +125 -0
  225. package/dist/esm/write-entry.d.ts.map +1 -0
  226. package/dist/esm/write-entry.js +625 -0
  227. package/dist/esm/write-entry.js.map +1 -0
  228. package/package.json +255 -40
  229. package/index.js +0 -18
  230. package/lib/create.js +0 -111
  231. package/lib/extract.js +0 -113
  232. package/lib/get-write-flag.js +0 -20
  233. package/lib/header.js +0 -304
  234. package/lib/high-level-opt.js +0 -29
  235. package/lib/large-numbers.js +0 -104
  236. package/lib/list.js +0 -139
  237. package/lib/mkdir.js +0 -229
  238. package/lib/mode-fix.js +0 -27
  239. package/lib/normalize-unicode.js +0 -12
  240. package/lib/pack.js +0 -432
  241. package/lib/parse.js +0 -552
  242. package/lib/path-reservations.js +0 -156
  243. package/lib/pax.js +0 -150
  244. package/lib/read-entry.js +0 -107
  245. package/lib/replace.js +0 -246
  246. package/lib/strip-absolute-path.js +0 -24
  247. package/lib/strip-trailing-slashes.js +0 -13
  248. package/lib/types.js +0 -44
  249. package/lib/unpack.js +0 -923
  250. package/lib/update.js +0 -40
  251. package/lib/warn-mixin.js +0 -24
  252. package/lib/winchars.js +0 -23
  253. package/lib/write-entry.js +0 -546
@@ -0,0 +1,890 @@
1
+ // the PEND/UNPEND stuff tracks whether we're ready to emit end/close yet.
2
+ // but the path reservations are required to avoid race conditions where
3
+ // parallelized unpack ops may mess with one another, due to dependencies
4
+ // (like a Link depending on its target) or destructive operations (like
5
+ // clobbering an fs object to create one of a different type.)
6
+ import * as fsm from '@isaacs/fs-minipass';
7
+ import assert from 'node:assert';
8
+ import { randomBytes } from 'node:crypto';
9
+ import fs from 'node:fs';
10
+ import path from 'node:path';
11
+ import { getWriteFlag } from './get-write-flag.js';
12
+ import { mkdir, mkdirSync } from './mkdir.js';
13
+ import { normalizeUnicode } from './normalize-unicode.js';
14
+ import { normalizeWindowsPath } from './normalize-windows-path.js';
15
+ import { Parser } from './parse.js';
16
+ import { stripAbsolutePath } from './strip-absolute-path.js';
17
+ import { stripTrailingSlashes } from './strip-trailing-slashes.js';
18
+ import * as wc from './winchars.js';
19
+ import { PathReservations } from './path-reservations.js';
20
+ const ONENTRY = Symbol('onEntry');
21
+ const CHECKFS = Symbol('checkFs');
22
+ const CHECKFS2 = Symbol('checkFs2');
23
+ const PRUNECACHE = Symbol('pruneCache');
24
+ const ISREUSABLE = Symbol('isReusable');
25
+ const MAKEFS = Symbol('makeFs');
26
+ const FILE = Symbol('file');
27
+ const DIRECTORY = Symbol('directory');
28
+ const LINK = Symbol('link');
29
+ const SYMLINK = Symbol('symlink');
30
+ const HARDLINK = Symbol('hardlink');
31
+ const UNSUPPORTED = Symbol('unsupported');
32
+ const CHECKPATH = Symbol('checkPath');
33
+ const MKDIR = Symbol('mkdir');
34
+ const ONERROR = Symbol('onError');
35
+ const PENDING = Symbol('pending');
36
+ const PEND = Symbol('pend');
37
+ const UNPEND = Symbol('unpend');
38
+ const ENDED = Symbol('ended');
39
+ const MAYBECLOSE = Symbol('maybeClose');
40
+ const SKIP = Symbol('skip');
41
+ const DOCHOWN = Symbol('doChown');
42
+ const UID = Symbol('uid');
43
+ const GID = Symbol('gid');
44
+ const CHECKED_CWD = Symbol('checkedCwd');
45
+ const platform = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
46
+ const isWindows = platform === 'win32';
47
+ const DEFAULT_MAX_DEPTH = 1024;
48
+ // Unlinks on Windows are not atomic.
49
+ //
50
+ // This means that if you have a file entry, followed by another
51
+ // file entry with an identical name, and you cannot re-use the file
52
+ // (because it's a hardlink, or because unlink:true is set, or it's
53
+ // Windows, which does not have useful nlink values), then the unlink
54
+ // will be committed to the disk AFTER the new file has been written
55
+ // over the old one, deleting the new file.
56
+ //
57
+ // To work around this, on Windows systems, we rename the file and then
58
+ // delete the renamed file. It's a sloppy kludge, but frankly, I do not
59
+ // know of a better way to do this, given windows' non-atomic unlink
60
+ // semantics.
61
+ //
62
+ // See: https://github.com/npm/node-tar/issues/183
63
+ /* c8 ignore start */
64
+ const unlinkFile = (path, cb) => {
65
+ if (!isWindows) {
66
+ return fs.unlink(path, cb);
67
+ }
68
+ const name = path + '.DELETE.' + randomBytes(16).toString('hex');
69
+ fs.rename(path, name, er => {
70
+ if (er) {
71
+ return cb(er);
72
+ }
73
+ fs.unlink(name, cb);
74
+ });
75
+ };
76
+ /* c8 ignore stop */
77
+ /* c8 ignore start */
78
+ const unlinkFileSync = (path) => {
79
+ if (!isWindows) {
80
+ return fs.unlinkSync(path);
81
+ }
82
+ const name = path + '.DELETE.' + randomBytes(16).toString('hex');
83
+ fs.renameSync(path, name);
84
+ fs.unlinkSync(name);
85
+ };
86
+ /* c8 ignore stop */
87
+ // this.gid, entry.gid, this.processUid
88
+ const uint32 = (a, b, c) => a !== undefined && a === a >>> 0
89
+ ? a
90
+ : b !== undefined && b === b >>> 0
91
+ ? b
92
+ : c;
93
+ // clear the cache if it's a case-insensitive unicode-squashing match.
94
+ // we can't know if the current file system is case-sensitive or supports
95
+ // unicode fully, so we check for similarity on the maximally compatible
96
+ // representation. Err on the side of pruning, since all it's doing is
97
+ // preventing lstats, and it's not the end of the world if we get a false
98
+ // positive.
99
+ // Note that on windows, we always drop the entire cache whenever a
100
+ // symbolic link is encountered, because 8.3 filenames are impossible
101
+ // to reason about, and collisions are hazards rather than just failures.
102
+ const cacheKeyNormalize = (path) => stripTrailingSlashes(normalizeWindowsPath(normalizeUnicode(path))).toLowerCase();
103
+ // remove all cache entries matching ${abs}/**
104
+ const pruneCache = (cache, abs) => {
105
+ abs = cacheKeyNormalize(abs);
106
+ for (const path of cache.keys()) {
107
+ const pnorm = cacheKeyNormalize(path);
108
+ if (pnorm === abs || pnorm.indexOf(abs + '/') === 0) {
109
+ cache.delete(path);
110
+ }
111
+ }
112
+ };
113
+ const dropCache = (cache) => {
114
+ for (const key of cache.keys()) {
115
+ cache.delete(key);
116
+ }
117
+ };
118
+ export class Unpack extends Parser {
119
+ [ENDED] = false;
120
+ [CHECKED_CWD] = false;
121
+ [PENDING] = 0;
122
+ reservations = new PathReservations();
123
+ transform;
124
+ writable = true;
125
+ readable = false;
126
+ dirCache;
127
+ uid;
128
+ gid;
129
+ setOwner;
130
+ preserveOwner;
131
+ processGid;
132
+ processUid;
133
+ maxDepth;
134
+ forceChown;
135
+ win32;
136
+ newer;
137
+ keep;
138
+ noMtime;
139
+ preservePaths;
140
+ unlink;
141
+ cwd;
142
+ strip;
143
+ processUmask;
144
+ umask;
145
+ dmode;
146
+ fmode;
147
+ chmod;
148
+ constructor(opt = {}) {
149
+ opt.ondone = () => {
150
+ this[ENDED] = true;
151
+ this[MAYBECLOSE]();
152
+ };
153
+ super(opt);
154
+ this.transform = opt.transform;
155
+ this.dirCache = opt.dirCache || new Map();
156
+ this.chmod = !!opt.chmod;
157
+ if (typeof opt.uid === 'number' || typeof opt.gid === 'number') {
158
+ // need both or neither
159
+ if (typeof opt.uid !== 'number' ||
160
+ typeof opt.gid !== 'number') {
161
+ throw new TypeError('cannot set owner without number uid and gid');
162
+ }
163
+ if (opt.preserveOwner) {
164
+ throw new TypeError('cannot preserve owner in archive and also set owner explicitly');
165
+ }
166
+ this.uid = opt.uid;
167
+ this.gid = opt.gid;
168
+ this.setOwner = true;
169
+ }
170
+ else {
171
+ this.uid = undefined;
172
+ this.gid = undefined;
173
+ this.setOwner = false;
174
+ }
175
+ // default true for root
176
+ if (opt.preserveOwner === undefined &&
177
+ typeof opt.uid !== 'number') {
178
+ this.preserveOwner = !!(process.getuid && process.getuid() === 0);
179
+ }
180
+ else {
181
+ this.preserveOwner = !!opt.preserveOwner;
182
+ }
183
+ this.processUid =
184
+ (this.preserveOwner || this.setOwner) && process.getuid
185
+ ? process.getuid()
186
+ : undefined;
187
+ this.processGid =
188
+ (this.preserveOwner || this.setOwner) && process.getgid
189
+ ? process.getgid()
190
+ : undefined;
191
+ // prevent excessively deep nesting of subfolders
192
+ // set to `Infinity` to remove this restriction
193
+ this.maxDepth =
194
+ typeof opt.maxDepth === 'number'
195
+ ? opt.maxDepth
196
+ : DEFAULT_MAX_DEPTH;
197
+ // mostly just for testing, but useful in some cases.
198
+ // Forcibly trigger a chown on every entry, no matter what
199
+ this.forceChown = opt.forceChown === true;
200
+ // turn ><?| in filenames into 0xf000-higher encoded forms
201
+ this.win32 = !!opt.win32 || isWindows;
202
+ // do not unpack over files that are newer than what's in the archive
203
+ this.newer = !!opt.newer;
204
+ // do not unpack over ANY files
205
+ this.keep = !!opt.keep;
206
+ // do not set mtime/atime of extracted entries
207
+ this.noMtime = !!opt.noMtime;
208
+ // allow .., absolute path entries, and unpacking through symlinks
209
+ // without this, warn and skip .., relativize absolutes, and error
210
+ // on symlinks in extraction path
211
+ this.preservePaths = !!opt.preservePaths;
212
+ // unlink files and links before writing. This breaks existing hard
213
+ // links, and removes symlink directories rather than erroring
214
+ this.unlink = !!opt.unlink;
215
+ this.cwd = normalizeWindowsPath(path.resolve(opt.cwd || process.cwd()));
216
+ this.strip = Number(opt.strip) || 0;
217
+ // if we're not chmodding, then we don't need the process umask
218
+ this.processUmask = !this.chmod
219
+ ? 0
220
+ : typeof opt.processUmask === 'number'
221
+ ? opt.processUmask
222
+ : process.umask();
223
+ this.umask =
224
+ typeof opt.umask === 'number' ? opt.umask : this.processUmask;
225
+ // default mode for dirs created as parents
226
+ this.dmode = opt.dmode || 0o0777 & ~this.umask;
227
+ this.fmode = opt.fmode || 0o0666 & ~this.umask;
228
+ this.on('entry', entry => this[ONENTRY](entry));
229
+ }
230
+ // a bad or damaged archive is a warning for Parser, but an error
231
+ // when extracting. Mark those errors as unrecoverable, because
232
+ // the Unpack contract cannot be met.
233
+ warn(code, msg, data = {}) {
234
+ if (code === 'TAR_BAD_ARCHIVE' || code === 'TAR_ABORT') {
235
+ data.recoverable = false;
236
+ }
237
+ return super.warn(code, msg, data);
238
+ }
239
+ [MAYBECLOSE]() {
240
+ if (this[ENDED] && this[PENDING] === 0) {
241
+ this.emit('prefinish');
242
+ this.emit('finish');
243
+ this.emit('end');
244
+ }
245
+ }
246
+ [CHECKPATH](entry) {
247
+ const p = normalizeWindowsPath(entry.path);
248
+ const parts = p.split('/');
249
+ if (this.strip) {
250
+ if (parts.length < this.strip) {
251
+ return false;
252
+ }
253
+ if (entry.type === 'Link') {
254
+ const linkparts = normalizeWindowsPath(String(entry.linkpath)).split('/');
255
+ if (linkparts.length >= this.strip) {
256
+ entry.linkpath = linkparts.slice(this.strip).join('/');
257
+ }
258
+ else {
259
+ return false;
260
+ }
261
+ }
262
+ parts.splice(0, this.strip);
263
+ entry.path = parts.join('/');
264
+ }
265
+ if (isFinite(this.maxDepth) && parts.length > this.maxDepth) {
266
+ this.warn('TAR_ENTRY_ERROR', 'path excessively deep', {
267
+ entry,
268
+ path: p,
269
+ depth: parts.length,
270
+ maxDepth: this.maxDepth,
271
+ });
272
+ return false;
273
+ }
274
+ if (!this.preservePaths) {
275
+ if (parts.includes('..') ||
276
+ /* c8 ignore next */
277
+ (isWindows && /^[a-z]:\.\.$/i.test(parts[0] ?? ''))) {
278
+ this.warn('TAR_ENTRY_ERROR', `path contains '..'`, {
279
+ entry,
280
+ path: p,
281
+ });
282
+ return false;
283
+ }
284
+ // strip off the root
285
+ const [root, stripped] = stripAbsolutePath(p);
286
+ if (root) {
287
+ entry.path = String(stripped);
288
+ this.warn('TAR_ENTRY_INFO', `stripping ${root} from absolute path`, {
289
+ entry,
290
+ path: p,
291
+ });
292
+ }
293
+ }
294
+ if (path.isAbsolute(entry.path)) {
295
+ entry.absolute = normalizeWindowsPath(path.resolve(entry.path));
296
+ }
297
+ else {
298
+ entry.absolute = normalizeWindowsPath(path.resolve(this.cwd, entry.path));
299
+ }
300
+ // if we somehow ended up with a path that escapes the cwd, and we are
301
+ // not in preservePaths mode, then something is fishy! This should have
302
+ // been prevented above, so ignore this for coverage.
303
+ /* c8 ignore start - defense in depth */
304
+ if (!this.preservePaths &&
305
+ typeof entry.absolute === 'string' &&
306
+ entry.absolute.indexOf(this.cwd + '/') !== 0 &&
307
+ entry.absolute !== this.cwd) {
308
+ this.warn('TAR_ENTRY_ERROR', 'path escaped extraction target', {
309
+ entry,
310
+ path: normalizeWindowsPath(entry.path),
311
+ resolvedPath: entry.absolute,
312
+ cwd: this.cwd,
313
+ });
314
+ return false;
315
+ }
316
+ /* c8 ignore stop */
317
+ // an archive can set properties on the extraction directory, but it
318
+ // may not replace the cwd with a different kind of thing entirely.
319
+ if (entry.absolute === this.cwd &&
320
+ entry.type !== 'Directory' &&
321
+ entry.type !== 'GNUDumpDir') {
322
+ return false;
323
+ }
324
+ // only encode : chars that aren't drive letter indicators
325
+ if (this.win32) {
326
+ const { root: aRoot } = path.win32.parse(String(entry.absolute));
327
+ entry.absolute =
328
+ aRoot + wc.encode(String(entry.absolute).slice(aRoot.length));
329
+ const { root: pRoot } = path.win32.parse(entry.path);
330
+ entry.path = pRoot + wc.encode(entry.path.slice(pRoot.length));
331
+ }
332
+ return true;
333
+ }
334
+ [ONENTRY](entry) {
335
+ if (!this[CHECKPATH](entry)) {
336
+ return entry.resume();
337
+ }
338
+ assert.equal(typeof entry.absolute, 'string');
339
+ switch (entry.type) {
340
+ case 'Directory':
341
+ case 'GNUDumpDir':
342
+ if (entry.mode) {
343
+ entry.mode = entry.mode | 0o700;
344
+ }
345
+ // eslint-disable-next-line no-fallthrough
346
+ case 'File':
347
+ case 'OldFile':
348
+ case 'ContiguousFile':
349
+ case 'Link':
350
+ case 'SymbolicLink':
351
+ return this[CHECKFS](entry);
352
+ case 'CharacterDevice':
353
+ case 'BlockDevice':
354
+ case 'FIFO':
355
+ default:
356
+ return this[UNSUPPORTED](entry);
357
+ }
358
+ }
359
+ [ONERROR](er, entry) {
360
+ // Cwd has to exist, or else nothing works. That's serious.
361
+ // Other errors are warnings, which raise the error in strict
362
+ // mode, but otherwise continue on.
363
+ if (er.name === 'CwdError') {
364
+ this.emit('error', er);
365
+ }
366
+ else {
367
+ this.warn('TAR_ENTRY_ERROR', er, { entry });
368
+ this[UNPEND]();
369
+ entry.resume();
370
+ }
371
+ }
372
+ [MKDIR](dir, mode, cb) {
373
+ mkdir(normalizeWindowsPath(dir), {
374
+ uid: this.uid,
375
+ gid: this.gid,
376
+ processUid: this.processUid,
377
+ processGid: this.processGid,
378
+ umask: this.processUmask,
379
+ preserve: this.preservePaths,
380
+ unlink: this.unlink,
381
+ cache: this.dirCache,
382
+ cwd: this.cwd,
383
+ mode: mode,
384
+ }, cb);
385
+ }
386
+ [DOCHOWN](entry) {
387
+ // in preserve owner mode, chown if the entry doesn't match process
388
+ // in set owner mode, chown if setting doesn't match process
389
+ return (this.forceChown ||
390
+ (this.preserveOwner &&
391
+ ((typeof entry.uid === 'number' &&
392
+ entry.uid !== this.processUid) ||
393
+ (typeof entry.gid === 'number' &&
394
+ entry.gid !== this.processGid))) ||
395
+ (typeof this.uid === 'number' &&
396
+ this.uid !== this.processUid) ||
397
+ (typeof this.gid === 'number' && this.gid !== this.processGid));
398
+ }
399
+ [UID](entry) {
400
+ return uint32(this.uid, entry.uid, this.processUid);
401
+ }
402
+ [GID](entry) {
403
+ return uint32(this.gid, entry.gid, this.processGid);
404
+ }
405
+ [FILE](entry, fullyDone) {
406
+ const mode = typeof entry.mode === 'number'
407
+ ? entry.mode & 0o7777
408
+ : this.fmode;
409
+ const stream = new fsm.WriteStream(String(entry.absolute), {
410
+ // slight lie, but it can be numeric flags
411
+ flags: getWriteFlag(entry.size),
412
+ mode: mode,
413
+ autoClose: false,
414
+ });
415
+ stream.on('error', (er) => {
416
+ if (stream.fd) {
417
+ fs.close(stream.fd, () => { });
418
+ }
419
+ // flush all the data out so that we aren't left hanging
420
+ // if the error wasn't actually fatal. otherwise the parse
421
+ // is blocked, and we never proceed.
422
+ stream.write = () => true;
423
+ this[ONERROR](er, entry);
424
+ fullyDone();
425
+ });
426
+ let actions = 1;
427
+ const done = (er) => {
428
+ if (er) {
429
+ /* c8 ignore start - we should always have a fd by now */
430
+ if (stream.fd) {
431
+ fs.close(stream.fd, () => { });
432
+ }
433
+ /* c8 ignore stop */
434
+ this[ONERROR](er, entry);
435
+ fullyDone();
436
+ return;
437
+ }
438
+ if (--actions === 0) {
439
+ if (stream.fd !== undefined) {
440
+ fs.close(stream.fd, er => {
441
+ if (er) {
442
+ this[ONERROR](er, entry);
443
+ }
444
+ else {
445
+ this[UNPEND]();
446
+ }
447
+ fullyDone();
448
+ });
449
+ }
450
+ }
451
+ };
452
+ stream.on('finish', () => {
453
+ // if futimes fails, try utimes
454
+ // if utimes fails, fail with the original error
455
+ // same for fchown/chown
456
+ const abs = String(entry.absolute);
457
+ const fd = stream.fd;
458
+ if (typeof fd === 'number' && entry.mtime && !this.noMtime) {
459
+ actions++;
460
+ const atime = entry.atime || new Date();
461
+ const mtime = entry.mtime;
462
+ fs.futimes(fd, atime, mtime, er => er
463
+ ? fs.utimes(abs, atime, mtime, er2 => done(er2 && er))
464
+ : done());
465
+ }
466
+ if (typeof fd === 'number' && this[DOCHOWN](entry)) {
467
+ actions++;
468
+ const uid = this[UID](entry);
469
+ const gid = this[GID](entry);
470
+ if (typeof uid === 'number' && typeof gid === 'number') {
471
+ fs.fchown(fd, uid, gid, er => er
472
+ ? fs.chown(abs, uid, gid, er2 => done(er2 && er))
473
+ : done());
474
+ }
475
+ }
476
+ done();
477
+ });
478
+ const tx = this.transform ? this.transform(entry) || entry : entry;
479
+ if (tx !== entry) {
480
+ tx.on('error', (er) => {
481
+ this[ONERROR](er, entry);
482
+ fullyDone();
483
+ });
484
+ entry.pipe(tx);
485
+ }
486
+ tx.pipe(stream);
487
+ }
488
+ [DIRECTORY](entry, fullyDone) {
489
+ const mode = typeof entry.mode === 'number'
490
+ ? entry.mode & 0o7777
491
+ : this.dmode;
492
+ this[MKDIR](String(entry.absolute), mode, er => {
493
+ if (er) {
494
+ this[ONERROR](er, entry);
495
+ fullyDone();
496
+ return;
497
+ }
498
+ let actions = 1;
499
+ const done = () => {
500
+ if (--actions === 0) {
501
+ fullyDone();
502
+ this[UNPEND]();
503
+ entry.resume();
504
+ }
505
+ };
506
+ if (entry.mtime && !this.noMtime) {
507
+ actions++;
508
+ fs.utimes(String(entry.absolute), entry.atime || new Date(), entry.mtime, done);
509
+ }
510
+ if (this[DOCHOWN](entry)) {
511
+ actions++;
512
+ fs.chown(String(entry.absolute), Number(this[UID](entry)), Number(this[GID](entry)), done);
513
+ }
514
+ done();
515
+ });
516
+ }
517
+ [UNSUPPORTED](entry) {
518
+ entry.unsupported = true;
519
+ this.warn('TAR_ENTRY_UNSUPPORTED', `unsupported entry type: ${entry.type}`, { entry });
520
+ entry.resume();
521
+ }
522
+ [SYMLINK](entry, done) {
523
+ this[LINK](entry, String(entry.linkpath), 'symlink', done);
524
+ }
525
+ [HARDLINK](entry, done) {
526
+ const linkpath = normalizeWindowsPath(path.resolve(this.cwd, String(entry.linkpath)));
527
+ this[LINK](entry, linkpath, 'link', done);
528
+ }
529
+ [PEND]() {
530
+ this[PENDING]++;
531
+ }
532
+ [UNPEND]() {
533
+ this[PENDING]--;
534
+ this[MAYBECLOSE]();
535
+ }
536
+ [SKIP](entry) {
537
+ this[UNPEND]();
538
+ entry.resume();
539
+ }
540
+ // Check if we can reuse an existing filesystem entry safely and
541
+ // overwrite it, rather than unlinking and recreating
542
+ // Windows doesn't report a useful nlink, so we just never reuse entries
543
+ [ISREUSABLE](entry, st) {
544
+ return (entry.type === 'File' &&
545
+ !this.unlink &&
546
+ st.isFile() &&
547
+ st.nlink <= 1 &&
548
+ !isWindows);
549
+ }
550
+ // check if a thing is there, and if so, try to clobber it
551
+ [CHECKFS](entry) {
552
+ this[PEND]();
553
+ const paths = [entry.path];
554
+ if (entry.linkpath) {
555
+ paths.push(entry.linkpath);
556
+ }
557
+ this.reservations.reserve(paths, done => this[CHECKFS2](entry, done));
558
+ }
559
+ [PRUNECACHE](entry) {
560
+ // if we are not creating a directory, and the path is in the dirCache,
561
+ // then that means we are about to delete the directory we created
562
+ // previously, and it is no longer going to be a directory, and neither
563
+ // is any of its children.
564
+ // If a symbolic link is encountered, all bets are off. There is no
565
+ // reasonable way to sanitize the cache in such a way we will be able to
566
+ // avoid having filesystem collisions. If this happens with a non-symlink
567
+ // entry, it'll just fail to unpack, but a symlink to a directory, using an
568
+ // 8.3 shortname or certain unicode attacks, can evade detection and lead
569
+ // to arbitrary writes to anywhere on the system.
570
+ if (entry.type === 'SymbolicLink') {
571
+ dropCache(this.dirCache);
572
+ }
573
+ else if (entry.type !== 'Directory') {
574
+ pruneCache(this.dirCache, String(entry.absolute));
575
+ }
576
+ }
577
+ [CHECKFS2](entry, fullyDone) {
578
+ this[PRUNECACHE](entry);
579
+ const done = (er) => {
580
+ this[PRUNECACHE](entry);
581
+ fullyDone(er);
582
+ };
583
+ const checkCwd = () => {
584
+ this[MKDIR](this.cwd, this.dmode, er => {
585
+ if (er) {
586
+ this[ONERROR](er, entry);
587
+ done();
588
+ return;
589
+ }
590
+ this[CHECKED_CWD] = true;
591
+ start();
592
+ });
593
+ };
594
+ const start = () => {
595
+ if (entry.absolute !== this.cwd) {
596
+ const parent = normalizeWindowsPath(path.dirname(String(entry.absolute)));
597
+ if (parent !== this.cwd) {
598
+ return this[MKDIR](parent, this.dmode, er => {
599
+ if (er) {
600
+ this[ONERROR](er, entry);
601
+ done();
602
+ return;
603
+ }
604
+ afterMakeParent();
605
+ });
606
+ }
607
+ }
608
+ afterMakeParent();
609
+ };
610
+ const afterMakeParent = () => {
611
+ fs.lstat(String(entry.absolute), (lstatEr, st) => {
612
+ if (st &&
613
+ (this.keep ||
614
+ /* c8 ignore next */
615
+ (this.newer && st.mtime > (entry.mtime ?? st.mtime)))) {
616
+ this[SKIP](entry);
617
+ done();
618
+ return;
619
+ }
620
+ if (lstatEr || this[ISREUSABLE](entry, st)) {
621
+ return this[MAKEFS](null, entry, done);
622
+ }
623
+ if (st.isDirectory()) {
624
+ if (entry.type === 'Directory') {
625
+ const needChmod = this.chmod &&
626
+ entry.mode &&
627
+ (st.mode & 0o7777) !== entry.mode;
628
+ const afterChmod = (er) => this[MAKEFS](er ?? null, entry, done);
629
+ if (!needChmod) {
630
+ return afterChmod();
631
+ }
632
+ return fs.chmod(String(entry.absolute), Number(entry.mode), afterChmod);
633
+ }
634
+ // Not a dir entry, have to remove it.
635
+ // NB: the only way to end up with an entry that is the cwd
636
+ // itself, in such a way that == does not detect, is a
637
+ // tricky windows absolute path with UNC or 8.3 parts (and
638
+ // preservePaths:true, or else it will have been stripped).
639
+ // In that case, the user has opted out of path protections
640
+ // explicitly, so if they blow away the cwd, c'est la vie.
641
+ if (entry.absolute !== this.cwd) {
642
+ return fs.rmdir(String(entry.absolute), (er) => this[MAKEFS](er ?? null, entry, done));
643
+ }
644
+ }
645
+ // not a dir, and not reusable
646
+ // don't remove if the cwd, we want that error
647
+ if (entry.absolute === this.cwd) {
648
+ return this[MAKEFS](null, entry, done);
649
+ }
650
+ unlinkFile(String(entry.absolute), er => this[MAKEFS](er ?? null, entry, done));
651
+ });
652
+ };
653
+ if (this[CHECKED_CWD]) {
654
+ start();
655
+ }
656
+ else {
657
+ checkCwd();
658
+ }
659
+ }
660
+ [MAKEFS](er, entry, done) {
661
+ if (er) {
662
+ this[ONERROR](er, entry);
663
+ done();
664
+ return;
665
+ }
666
+ switch (entry.type) {
667
+ case 'File':
668
+ case 'OldFile':
669
+ case 'ContiguousFile':
670
+ return this[FILE](entry, done);
671
+ case 'Link':
672
+ return this[HARDLINK](entry, done);
673
+ case 'SymbolicLink':
674
+ return this[SYMLINK](entry, done);
675
+ case 'Directory':
676
+ case 'GNUDumpDir':
677
+ return this[DIRECTORY](entry, done);
678
+ }
679
+ }
680
+ [LINK](entry, linkpath, link, done) {
681
+ // XXX: get the type ('symlink' or 'junction') for windows
682
+ fs[link](linkpath, String(entry.absolute), er => {
683
+ if (er) {
684
+ this[ONERROR](er, entry);
685
+ }
686
+ else {
687
+ this[UNPEND]();
688
+ entry.resume();
689
+ }
690
+ done();
691
+ });
692
+ }
693
+ }
694
+ const callSync = (fn) => {
695
+ try {
696
+ return [null, fn()];
697
+ }
698
+ catch (er) {
699
+ return [er, null];
700
+ }
701
+ };
702
+ export class UnpackSync extends Unpack {
703
+ [MAKEFS](er, entry) {
704
+ return super[MAKEFS](er, entry, () => { });
705
+ }
706
+ [CHECKFS](entry) {
707
+ this[PRUNECACHE](entry);
708
+ if (!this[CHECKED_CWD]) {
709
+ const er = this[MKDIR](this.cwd, this.dmode);
710
+ if (er) {
711
+ return this[ONERROR](er, entry);
712
+ }
713
+ this[CHECKED_CWD] = true;
714
+ }
715
+ // don't bother to make the parent if the current entry is the cwd,
716
+ // we've already checked it.
717
+ if (entry.absolute !== this.cwd) {
718
+ const parent = normalizeWindowsPath(path.dirname(String(entry.absolute)));
719
+ if (parent !== this.cwd) {
720
+ const mkParent = this[MKDIR](parent, this.dmode);
721
+ if (mkParent) {
722
+ return this[ONERROR](mkParent, entry);
723
+ }
724
+ }
725
+ }
726
+ const [lstatEr, st] = callSync(() => fs.lstatSync(String(entry.absolute)));
727
+ if (st &&
728
+ (this.keep ||
729
+ /* c8 ignore next */
730
+ (this.newer && st.mtime > (entry.mtime ?? st.mtime)))) {
731
+ return this[SKIP](entry);
732
+ }
733
+ if (lstatEr || this[ISREUSABLE](entry, st)) {
734
+ return this[MAKEFS](null, entry);
735
+ }
736
+ if (st.isDirectory()) {
737
+ if (entry.type === 'Directory') {
738
+ const needChmod = this.chmod &&
739
+ entry.mode &&
740
+ (st.mode & 0o7777) !== entry.mode;
741
+ const [er] = needChmod
742
+ ? callSync(() => {
743
+ fs.chmodSync(String(entry.absolute), Number(entry.mode));
744
+ })
745
+ : [];
746
+ return this[MAKEFS](er, entry);
747
+ }
748
+ // not a dir entry, have to remove it
749
+ const [er] = callSync(() => fs.rmdirSync(String(entry.absolute)));
750
+ this[MAKEFS](er, entry);
751
+ }
752
+ // not a dir, and not reusable.
753
+ // don't remove if it's the cwd, since we want that error.
754
+ const [er] = entry.absolute === this.cwd
755
+ ? []
756
+ : callSync(() => unlinkFileSync(String(entry.absolute)));
757
+ this[MAKEFS](er, entry);
758
+ }
759
+ [FILE](entry, done) {
760
+ const mode = typeof entry.mode === 'number'
761
+ ? entry.mode & 0o7777
762
+ : this.fmode;
763
+ const oner = (er) => {
764
+ let closeError;
765
+ try {
766
+ fs.closeSync(fd);
767
+ }
768
+ catch (e) {
769
+ closeError = e;
770
+ }
771
+ if (er || closeError) {
772
+ this[ONERROR](er || closeError, entry);
773
+ }
774
+ done();
775
+ };
776
+ let fd;
777
+ try {
778
+ fd = fs.openSync(String(entry.absolute), getWriteFlag(entry.size), mode);
779
+ }
780
+ catch (er) {
781
+ return oner(er);
782
+ }
783
+ const tx = this.transform ? this.transform(entry) || entry : entry;
784
+ if (tx !== entry) {
785
+ tx.on('error', (er) => this[ONERROR](er, entry));
786
+ entry.pipe(tx);
787
+ }
788
+ tx.on('data', (chunk) => {
789
+ try {
790
+ fs.writeSync(fd, chunk, 0, chunk.length);
791
+ }
792
+ catch (er) {
793
+ oner(er);
794
+ }
795
+ });
796
+ tx.on('end', () => {
797
+ let er = null;
798
+ // try both, falling futimes back to utimes
799
+ // if either fails, handle the first error
800
+ if (entry.mtime && !this.noMtime) {
801
+ const atime = entry.atime || new Date();
802
+ const mtime = entry.mtime;
803
+ try {
804
+ fs.futimesSync(fd, atime, mtime);
805
+ }
806
+ catch (futimeser) {
807
+ try {
808
+ fs.utimesSync(String(entry.absolute), atime, mtime);
809
+ }
810
+ catch (utimeser) {
811
+ er = futimeser;
812
+ }
813
+ }
814
+ }
815
+ if (this[DOCHOWN](entry)) {
816
+ const uid = this[UID](entry);
817
+ const gid = this[GID](entry);
818
+ try {
819
+ fs.fchownSync(fd, Number(uid), Number(gid));
820
+ }
821
+ catch (fchowner) {
822
+ try {
823
+ fs.chownSync(String(entry.absolute), Number(uid), Number(gid));
824
+ }
825
+ catch (chowner) {
826
+ er = er || fchowner;
827
+ }
828
+ }
829
+ }
830
+ oner(er);
831
+ });
832
+ }
833
+ [DIRECTORY](entry, done) {
834
+ const mode = typeof entry.mode === 'number'
835
+ ? entry.mode & 0o7777
836
+ : this.dmode;
837
+ const er = this[MKDIR](String(entry.absolute), mode);
838
+ if (er) {
839
+ this[ONERROR](er, entry);
840
+ done();
841
+ return;
842
+ }
843
+ if (entry.mtime && !this.noMtime) {
844
+ try {
845
+ fs.utimesSync(String(entry.absolute), entry.atime || new Date(), entry.mtime);
846
+ /* c8 ignore next */
847
+ }
848
+ catch (er) { }
849
+ }
850
+ if (this[DOCHOWN](entry)) {
851
+ try {
852
+ fs.chownSync(String(entry.absolute), Number(this[UID](entry)), Number(this[GID](entry)));
853
+ }
854
+ catch (er) { }
855
+ }
856
+ done();
857
+ entry.resume();
858
+ }
859
+ [MKDIR](dir, mode) {
860
+ try {
861
+ return mkdirSync(normalizeWindowsPath(dir), {
862
+ uid: this.uid,
863
+ gid: this.gid,
864
+ processUid: this.processUid,
865
+ processGid: this.processGid,
866
+ umask: this.processUmask,
867
+ preserve: this.preservePaths,
868
+ unlink: this.unlink,
869
+ cache: this.dirCache,
870
+ cwd: this.cwd,
871
+ mode: mode,
872
+ });
873
+ }
874
+ catch (er) {
875
+ return er;
876
+ }
877
+ }
878
+ [LINK](entry, linkpath, link, done) {
879
+ const ls = `${link}Sync`;
880
+ try {
881
+ fs[ls](linkpath, String(entry.absolute));
882
+ done();
883
+ entry.resume();
884
+ }
885
+ catch (er) {
886
+ return this[ONERROR](er, entry);
887
+ }
888
+ }
889
+ }
890
+ //# sourceMappingURL=unpack.js.map