muhammara 3.1.1 → 3.3.0
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.
- package/CHANGELOG.md +35 -2
- package/PDFRStreamForBuffer.js +7 -2
- package/PDFRStreamForFile.js +7 -2
- package/binding.gyp +2 -2
- package/muhammara.d.ts +1 -1
- package/node_modules/tar/README.md +37 -9
- package/node_modules/tar/lib/create.js +16 -9
- package/node_modules/tar/lib/extract.js +16 -10
- package/node_modules/tar/lib/header.js +50 -34
- package/node_modules/tar/lib/large-numbers.js +22 -17
- package/node_modules/tar/lib/list.js +20 -13
- package/node_modules/tar/lib/mkdir.js +40 -24
- package/node_modules/tar/lib/mode-fix.js +8 -4
- package/node_modules/tar/lib/normalize-unicode.js +3 -2
- package/node_modules/tar/lib/pack.js +54 -31
- package/node_modules/tar/lib/parse.js +74 -46
- package/node_modules/tar/lib/path-reservations.js +26 -18
- package/node_modules/tar/lib/pax.js +15 -8
- package/node_modules/tar/lib/read-entry.js +14 -7
- package/node_modules/tar/lib/replace.js +50 -27
- package/node_modules/tar/lib/strip-absolute-path.js +1 -1
- package/node_modules/tar/lib/unpack.js +73 -44
- package/node_modules/tar/lib/update.js +8 -4
- package/node_modules/tar/lib/warn-mixin.js +7 -4
- package/node_modules/tar/lib/write-entry.js +44 -23
- package/node_modules/tar/package.json +44 -30
- package/package.json +1 -1
- package/src/ObjectByteReaderWithPosition.cpp +15 -0
- package/src/ObjectByteReaderWithPosition.h +1 -0
- package/src/deps/FreeType/binding.gyp +10 -0
- package/src/deps/LibAesgm/binding.gyp +10 -0
- package/src/deps/LibJpeg/binding.gyp +10 -0
- package/src/deps/LibPng/binding.gyp +11 -1
- package/src/deps/LibTiff/binding.gyp +10 -0
- package/src/deps/PDFWriter/IByteReaderWithPosition.h +4 -0
- package/src/deps/PDFWriter/InputBufferedStream.cpp +10 -3
- package/src/deps/PDFWriter/InputBufferedStream.h +2 -0
- package/src/deps/PDFWriter/InputByteArrayStream.cpp +9 -2
- package/src/deps/PDFWriter/InputByteArrayStream.h +2 -0
- package/src/deps/PDFWriter/InputFileStream.cpp +9 -2
- package/src/deps/PDFWriter/InputFileStream.h +2 -0
- package/src/deps/PDFWriter/InputStringBufferStream.cpp +10 -3
- package/src/deps/PDFWriter/InputStringBufferStream.h +2 -0
- package/src/deps/PDFWriter/InputStringStream.cpp +7 -0
- package/src/deps/PDFWriter/InputStringStream.h +2 -0
- package/src/deps/PDFWriter/PDFParser.cpp +12 -6
- package/src/deps/PDFWriter/binding.gyp +10 -0
- package/src/deps/ZLib/binding.gyp +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,29 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [3.3.0] - 2022-11-05
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Typescript definition of member buffer of PDFWStreamForBuffer fixed
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- Updated github actions to get rid of some deprecation warnings in gha ci
|
|
19
|
+
- Pin python 3 version for builds
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
- Electron 21.0.0, 21.1.0 and 21.2.0
|
|
24
|
+
|
|
25
|
+
## [3.2.0] - 2022-10-26
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
- Add electron 20.3.3
|
|
30
|
+
- Ignore extra data above the header and below the footer in PDF Parser
|
|
31
|
+
- Add node 19.0.0
|
|
32
|
+
|
|
10
33
|
## [3.1.1] - 2022-10-23
|
|
11
34
|
|
|
12
35
|
### Fixed
|
|
@@ -21,6 +44,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
21
44
|
|
|
22
45
|
### Added
|
|
23
46
|
|
|
47
|
+
- Electron 21.0
|
|
24
48
|
- Node 18
|
|
25
49
|
- Electron 20.0, 20.1, 20.2
|
|
26
50
|
- Prettier as dev dependency and basics
|
|
@@ -48,6 +72,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
48
72
|
- Node < 11 and Electron < 11 removed
|
|
49
73
|
- Renamed typo exported value from eTokenSeprator to eTokenSeparator
|
|
50
74
|
|
|
75
|
+
## [2.6.1] - 2022-10-23
|
|
76
|
+
|
|
77
|
+
### Fixed
|
|
78
|
+
|
|
79
|
+
- Backport: NPE in parser when file ends before it really starts
|
|
80
|
+
|
|
51
81
|
## [2.6.0] - 2022-06-30
|
|
52
82
|
|
|
53
83
|
### Changed
|
|
@@ -280,10 +310,13 @@ with the following changes.
|
|
|
280
310
|
|
|
281
311
|
- Initial release
|
|
282
312
|
|
|
283
|
-
[unreleased]: https://github.com/julianhille/MuhammaraJS/compare/3.
|
|
313
|
+
[unreleased]: https://github.com/julianhille/MuhammaraJS/compare/3.3.0...HEAD
|
|
314
|
+
[3.3.0]: https://github.com/julianhille/MuhammaraJS/compare/3.2.0...3.3.0
|
|
315
|
+
[3.2.0]: https://github.com/julianhille/MuhammaraJS/compare/3.1.1...3.2.0
|
|
284
316
|
[3.1.1]: https://github.com/julianhille/MuhammaraJS/compare/3.1.0...3.1.1
|
|
285
317
|
[3.1.0]: https://github.com/julianhille/MuhammaraJS/compare/3.0.0...3.1.0
|
|
286
|
-
[3.0.0]: https://github.com/julianhille/MuhammaraJS/compare/2.6.
|
|
318
|
+
[3.0.0]: https://github.com/julianhille/MuhammaraJS/compare/2.6.1...3.0.0
|
|
319
|
+
[2.6.1]: https://github.com/julianhille/MuhammaraJS/compare/2.6.0...2.6.1
|
|
287
320
|
[2.6.0]: https://github.com/julianhille/MuhammaraJS/compare/2.5.0...2.6.0
|
|
288
321
|
[2.5.0]: https://github.com/julianhille/MuhammaraJS/compare/2.4.0...2.5.0
|
|
289
322
|
[2.4.0]: https://github.com/julianhille/MuhammaraJS/compare/2.3.0...2.4.0
|
package/PDFRStreamForBuffer.js
CHANGED
|
@@ -8,6 +8,7 @@ function PDFRStreamForBuffer(buffer) {
|
|
|
8
8
|
this.innerArray = Array.prototype.slice.call(buffer, 0);
|
|
9
9
|
this.rposition = 0;
|
|
10
10
|
this.fileSize = this.innerArray.length;
|
|
11
|
+
this.mStartPosition = 0;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
PDFRStreamForBuffer.prototype.read = function (inAmount) {
|
|
@@ -25,7 +26,7 @@ PDFRStreamForBuffer.prototype.notEnded = function () {
|
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
PDFRStreamForBuffer.prototype.setPosition = function (inPosition) {
|
|
28
|
-
this.rposition = inPosition;
|
|
29
|
+
this.rposition = this.mStartPosition + inPosition;
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
PDFRStreamForBuffer.prototype.setPositionFromEnd = function (inPosition) {
|
|
@@ -37,7 +38,11 @@ PDFRStreamForBuffer.prototype.skip = function (inAmount) {
|
|
|
37
38
|
};
|
|
38
39
|
|
|
39
40
|
PDFRStreamForBuffer.prototype.getCurrentPosition = function () {
|
|
40
|
-
return this.rposition;
|
|
41
|
+
return this.rposition - this.mStartPosition;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
PDFRStreamForBuffer.prototype.moveStartPosition = function (inPosition) {
|
|
45
|
+
this.mStartPosition = inPosition;
|
|
41
46
|
};
|
|
42
47
|
|
|
43
48
|
module.exports = PDFRStreamForBuffer;
|
package/PDFRStreamForFile.js
CHANGED
|
@@ -8,6 +8,7 @@ function PDFRStreamForFile(inPath) {
|
|
|
8
8
|
this.path = inPath;
|
|
9
9
|
this.rposition = 0;
|
|
10
10
|
this.fileSize = fs.statSync(inPath)["size"];
|
|
11
|
+
this.mStartPosition = 0;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
PDFRStreamForFile.prototype.read = function (inAmount) {
|
|
@@ -25,7 +26,7 @@ PDFRStreamForFile.prototype.notEnded = function () {
|
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
PDFRStreamForFile.prototype.setPosition = function (inPosition) {
|
|
28
|
-
this.rposition = inPosition;
|
|
29
|
+
this.rposition = this.mStartPosition + inPosition;
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
PDFRStreamForFile.prototype.setPositionFromEnd = function (inPosition) {
|
|
@@ -37,7 +38,11 @@ PDFRStreamForFile.prototype.skip = function (inAmount) {
|
|
|
37
38
|
};
|
|
38
39
|
|
|
39
40
|
PDFRStreamForFile.prototype.getCurrentPosition = function () {
|
|
40
|
-
return this.rposition;
|
|
41
|
+
return this.rposition - this.mStartPosition;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
PDFRStreamForFile.prototype.moveStartPosition = function (inPosition) {
|
|
45
|
+
this.mStartPosition = inPosition;
|
|
41
46
|
};
|
|
42
47
|
|
|
43
48
|
function noop() {}
|
package/binding.gyp
CHANGED
package/muhammara.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# node-tar
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Fast and full-featured Tar for Node.js
|
|
4
4
|
|
|
5
5
|
The API is designed to mimic the behavior of `tar(1)` on unix systems.
|
|
6
6
|
If you are familiar with how tar works, most of this will hopefully be
|
|
@@ -209,6 +209,19 @@ tar.t({
|
|
|
209
209
|
})
|
|
210
210
|
```
|
|
211
211
|
|
|
212
|
+
For example, to just get the list of filenames from an archive:
|
|
213
|
+
|
|
214
|
+
```js
|
|
215
|
+
const getEntryFilenames = async tarballFilename => {
|
|
216
|
+
const filenames = []
|
|
217
|
+
await tar.t({
|
|
218
|
+
file: tarballFilename,
|
|
219
|
+
onentry: entry => filenames.push(entry.path),
|
|
220
|
+
})
|
|
221
|
+
return filenames
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
212
225
|
To replicate `cat my-tarball.tgz | tar t` do:
|
|
213
226
|
|
|
214
227
|
```js
|
|
@@ -223,6 +236,18 @@ When the function returns, it's already done. Sync methods without a
|
|
|
223
236
|
file argument return a sync stream, which flushes immediately. But,
|
|
224
237
|
of course, it still won't be done until you `.end()` it.
|
|
225
238
|
|
|
239
|
+
```js
|
|
240
|
+
const getEntryFilenamesSync = tarballFilename => {
|
|
241
|
+
const filenames = []
|
|
242
|
+
tar.t({
|
|
243
|
+
file: tarballFilename,
|
|
244
|
+
onentry: entry => filenames.push(entry.path),
|
|
245
|
+
sync: true,
|
|
246
|
+
})
|
|
247
|
+
return filenames
|
|
248
|
+
}
|
|
249
|
+
```
|
|
250
|
+
|
|
226
251
|
To filter entries, add `filter: <function>` to the options.
|
|
227
252
|
Tar-creating methods call the filter with `filter(path, stat)`.
|
|
228
253
|
Tar-reading methods (including extraction) call the filter with
|
|
@@ -429,15 +454,18 @@ no paths are provided, then all the entries are listed.
|
|
|
429
454
|
|
|
430
455
|
If the archive is gzipped, then tar will detect this and unzip it.
|
|
431
456
|
|
|
432
|
-
|
|
433
|
-
`tar.ReadEntry` objects. However, they don't
|
|
434
|
-
events. (If you want to get actual readable
|
|
435
|
-
`tar.Parse` class instead.)
|
|
457
|
+
If the `file` option is _not_ provided, then returns an event emitter that
|
|
458
|
+
emits `entry` events with `tar.ReadEntry` objects. However, they don't
|
|
459
|
+
emit `'data'` or `'end'` events. (If you want to get actual readable
|
|
460
|
+
entries, use the `tar.Parse` class instead.)
|
|
461
|
+
|
|
462
|
+
If a `file` option _is_ provided, then the return value will be a promise
|
|
463
|
+
that resolves when the file has been fully traversed in async mode, or
|
|
464
|
+
`undefined` if `sync: true` is set. Thus, you _must_ specify an `onentry`
|
|
465
|
+
method in order to do anything useful with the data it parses.
|
|
436
466
|
|
|
437
467
|
The following options are supported:
|
|
438
468
|
|
|
439
|
-
- `cwd` Extract files relative to the specified directory. Defaults
|
|
440
|
-
to `process.cwd()`. [Alias: `C`]
|
|
441
469
|
- `file` The archive file to list. If not specified, then a
|
|
442
470
|
Writable stream is returned where the archive data should be
|
|
443
471
|
written. [Alias: `f`]
|
|
@@ -449,8 +477,8 @@ The following options are supported:
|
|
|
449
477
|
entry being listed. Return `true` to emit the entry from the
|
|
450
478
|
archive, or `false` to skip it.
|
|
451
479
|
- `onentry` A function that gets called with `(entry)` for each entry
|
|
452
|
-
that passes the filter. This is important for when
|
|
453
|
-
|
|
480
|
+
that passes the filter. This is important for when `file` is set,
|
|
481
|
+
because there is no other way to do anything useful with this method.
|
|
454
482
|
- `maxReadSize` The maximum buffer size for `fs.read()` operations.
|
|
455
483
|
Defaults to 16 MB.
|
|
456
484
|
- `noResume` By default, `entry` streams are resumed immediately after
|
|
@@ -9,24 +9,29 @@ const t = require('./list.js')
|
|
|
9
9
|
const path = require('path')
|
|
10
10
|
|
|
11
11
|
module.exports = (opt_, files, cb) => {
|
|
12
|
-
if (typeof files === 'function')
|
|
12
|
+
if (typeof files === 'function') {
|
|
13
13
|
cb = files
|
|
14
|
+
}
|
|
14
15
|
|
|
15
|
-
if (Array.isArray(opt_))
|
|
16
|
+
if (Array.isArray(opt_)) {
|
|
16
17
|
files = opt_, opt_ = {}
|
|
18
|
+
}
|
|
17
19
|
|
|
18
|
-
if (!files || !Array.isArray(files) || !files.length)
|
|
20
|
+
if (!files || !Array.isArray(files) || !files.length) {
|
|
19
21
|
throw new TypeError('no files or directories specified')
|
|
22
|
+
}
|
|
20
23
|
|
|
21
24
|
files = Array.from(files)
|
|
22
25
|
|
|
23
26
|
const opt = hlo(opt_)
|
|
24
27
|
|
|
25
|
-
if (opt.sync && typeof cb === 'function')
|
|
28
|
+
if (opt.sync && typeof cb === 'function') {
|
|
26
29
|
throw new TypeError('callback not supported for sync tar functions')
|
|
30
|
+
}
|
|
27
31
|
|
|
28
|
-
if (!opt.file && typeof cb === 'function')
|
|
32
|
+
if (!opt.file && typeof cb === 'function') {
|
|
29
33
|
throw new TypeError('callback only supported with file option')
|
|
34
|
+
}
|
|
30
35
|
|
|
31
36
|
return opt.file && opt.sync ? createFileSync(opt, files)
|
|
32
37
|
: opt.file ? createFile(opt, files, cb)
|
|
@@ -65,13 +70,14 @@ const addFilesSync = (p, files) => {
|
|
|
65
70
|
files.forEach(file => {
|
|
66
71
|
if (file.charAt(0) === '@') {
|
|
67
72
|
t({
|
|
68
|
-
file: path.resolve(p.cwd, file.
|
|
73
|
+
file: path.resolve(p.cwd, file.slice(1)),
|
|
69
74
|
sync: true,
|
|
70
75
|
noResume: true,
|
|
71
76
|
onentry: entry => p.add(entry),
|
|
72
77
|
})
|
|
73
|
-
} else
|
|
78
|
+
} else {
|
|
74
79
|
p.add(file)
|
|
80
|
+
}
|
|
75
81
|
})
|
|
76
82
|
p.end()
|
|
77
83
|
}
|
|
@@ -81,12 +87,13 @@ const addFilesAsync = (p, files) => {
|
|
|
81
87
|
const file = files.shift()
|
|
82
88
|
if (file.charAt(0) === '@') {
|
|
83
89
|
return t({
|
|
84
|
-
file: path.resolve(p.cwd, file.
|
|
90
|
+
file: path.resolve(p.cwd, file.slice(1)),
|
|
85
91
|
noResume: true,
|
|
86
92
|
onentry: entry => p.add(entry),
|
|
87
93
|
}).then(_ => addFilesAsync(p, files))
|
|
88
|
-
} else
|
|
94
|
+
} else {
|
|
89
95
|
p.add(file)
|
|
96
|
+
}
|
|
90
97
|
}
|
|
91
98
|
p.end()
|
|
92
99
|
}
|
|
@@ -9,29 +9,35 @@ const path = require('path')
|
|
|
9
9
|
const stripSlash = require('./strip-trailing-slashes.js')
|
|
10
10
|
|
|
11
11
|
module.exports = (opt_, files, cb) => {
|
|
12
|
-
if (typeof opt_ === 'function')
|
|
12
|
+
if (typeof opt_ === 'function') {
|
|
13
13
|
cb = opt_, files = null, opt_ = {}
|
|
14
|
-
else if (Array.isArray(opt_))
|
|
14
|
+
} else if (Array.isArray(opt_)) {
|
|
15
15
|
files = opt_, opt_ = {}
|
|
16
|
+
}
|
|
16
17
|
|
|
17
|
-
if (typeof files === 'function')
|
|
18
|
+
if (typeof files === 'function') {
|
|
18
19
|
cb = files, files = null
|
|
20
|
+
}
|
|
19
21
|
|
|
20
|
-
if (!files)
|
|
22
|
+
if (!files) {
|
|
21
23
|
files = []
|
|
22
|
-
else
|
|
24
|
+
} else {
|
|
23
25
|
files = Array.from(files)
|
|
26
|
+
}
|
|
24
27
|
|
|
25
28
|
const opt = hlo(opt_)
|
|
26
29
|
|
|
27
|
-
if (opt.sync && typeof cb === 'function')
|
|
30
|
+
if (opt.sync && typeof cb === 'function') {
|
|
28
31
|
throw new TypeError('callback not supported for sync tar functions')
|
|
32
|
+
}
|
|
29
33
|
|
|
30
|
-
if (!opt.file && typeof cb === 'function')
|
|
34
|
+
if (!opt.file && typeof cb === 'function') {
|
|
31
35
|
throw new TypeError('callback only supported with file option')
|
|
36
|
+
}
|
|
32
37
|
|
|
33
|
-
if (files.length)
|
|
38
|
+
if (files.length) {
|
|
34
39
|
filesFilter(opt, files)
|
|
40
|
+
}
|
|
35
41
|
|
|
36
42
|
return opt.file && opt.sync ? extractFileSync(opt)
|
|
37
43
|
: opt.file ? extractFile(opt, cb)
|
|
@@ -87,9 +93,9 @@ const extractFile = (opt, cb) => {
|
|
|
87
93
|
// This trades a zero-byte read() syscall for a stat
|
|
88
94
|
// However, it will usually result in less memory allocation
|
|
89
95
|
fs.stat(file, (er, stat) => {
|
|
90
|
-
if (er)
|
|
96
|
+
if (er) {
|
|
91
97
|
reject(er)
|
|
92
|
-
else {
|
|
98
|
+
} else {
|
|
93
99
|
const stream = new fsm.ReadStream(file, {
|
|
94
100
|
readSize: readSize,
|
|
95
101
|
size: stat.size,
|
|
@@ -34,18 +34,21 @@ class Header {
|
|
|
34
34
|
this.atime = null
|
|
35
35
|
this.ctime = null
|
|
36
36
|
|
|
37
|
-
if (Buffer.isBuffer(data))
|
|
37
|
+
if (Buffer.isBuffer(data)) {
|
|
38
38
|
this.decode(data, off || 0, ex, gex)
|
|
39
|
-
else if (data)
|
|
39
|
+
} else if (data) {
|
|
40
40
|
this.set(data)
|
|
41
|
+
}
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
decode (buf, off, ex, gex) {
|
|
44
|
-
if (!off)
|
|
45
|
+
if (!off) {
|
|
45
46
|
off = 0
|
|
47
|
+
}
|
|
46
48
|
|
|
47
|
-
if (!buf || !(buf.length >= off + 512))
|
|
49
|
+
if (!buf || !(buf.length >= off + 512)) {
|
|
48
50
|
throw new Error('need 512 bytes for header')
|
|
51
|
+
}
|
|
49
52
|
|
|
50
53
|
this.path = decString(buf, off, 100)
|
|
51
54
|
this.mode = decNumber(buf, off + 100, 8)
|
|
@@ -62,18 +65,21 @@ class Header {
|
|
|
62
65
|
|
|
63
66
|
// old tar versions marked dirs as a file with a trailing /
|
|
64
67
|
this[TYPE] = decString(buf, off + 156, 1)
|
|
65
|
-
if (this[TYPE] === '')
|
|
68
|
+
if (this[TYPE] === '') {
|
|
66
69
|
this[TYPE] = '0'
|
|
67
|
-
|
|
70
|
+
}
|
|
71
|
+
if (this[TYPE] === '0' && this.path.slice(-1) === '/') {
|
|
68
72
|
this[TYPE] = '5'
|
|
73
|
+
}
|
|
69
74
|
|
|
70
75
|
// tar implementations sometimes incorrectly put the stat(dir).size
|
|
71
76
|
// as the size in the tarball, even though Directory entries are
|
|
72
77
|
// not able to have any body at all. In the very rare chance that
|
|
73
78
|
// it actually DOES have a body, we weren't going to do anything with
|
|
74
79
|
// it anyway, and it'll just be a warning about an invalid header.
|
|
75
|
-
if (this[TYPE] === '5')
|
|
80
|
+
if (this[TYPE] === '5') {
|
|
76
81
|
this.size = 0
|
|
82
|
+
}
|
|
77
83
|
|
|
78
84
|
this.linkpath = decString(buf, off + 157, 100)
|
|
79
85
|
if (buf.slice(off + 257, off + 265).toString() === 'ustar\u000000') {
|
|
@@ -87,23 +93,27 @@ class Header {
|
|
|
87
93
|
this.path = prefix + '/' + this.path
|
|
88
94
|
} else {
|
|
89
95
|
const prefix = decString(buf, off + 345, 130)
|
|
90
|
-
if (prefix)
|
|
96
|
+
if (prefix) {
|
|
91
97
|
this.path = prefix + '/' + this.path
|
|
98
|
+
}
|
|
92
99
|
this.atime = decDate(buf, off + 476, 12)
|
|
93
100
|
this.ctime = decDate(buf, off + 488, 12)
|
|
94
101
|
}
|
|
95
102
|
}
|
|
96
103
|
|
|
97
104
|
let sum = 8 * 0x20
|
|
98
|
-
for (let i = off; i < off + 148; i++)
|
|
105
|
+
for (let i = off; i < off + 148; i++) {
|
|
99
106
|
sum += buf[i]
|
|
107
|
+
}
|
|
100
108
|
|
|
101
|
-
for (let i = off + 156; i < off + 512; i++)
|
|
109
|
+
for (let i = off + 156; i < off + 512; i++) {
|
|
102
110
|
sum += buf[i]
|
|
111
|
+
}
|
|
103
112
|
|
|
104
113
|
this.cksumValid = sum === this.cksum
|
|
105
|
-
if (this.cksum === null && sum === 8 * 0x20)
|
|
114
|
+
if (this.cksum === null && sum === 8 * 0x20) {
|
|
106
115
|
this.nullBlock = true
|
|
116
|
+
}
|
|
107
117
|
}
|
|
108
118
|
|
|
109
119
|
[SLURP] (ex, global) {
|
|
@@ -111,8 +121,9 @@ class Header {
|
|
|
111
121
|
// we slurp in everything except for the path attribute in
|
|
112
122
|
// a global extended header, because that's weird.
|
|
113
123
|
if (ex[k] !== null && ex[k] !== undefined &&
|
|
114
|
-
!(global && k === 'path'))
|
|
124
|
+
!(global && k === 'path')) {
|
|
115
125
|
this[k] = ex[k]
|
|
126
|
+
}
|
|
116
127
|
}
|
|
117
128
|
}
|
|
118
129
|
|
|
@@ -122,11 +133,13 @@ class Header {
|
|
|
122
133
|
off = 0
|
|
123
134
|
}
|
|
124
135
|
|
|
125
|
-
if (!off)
|
|
136
|
+
if (!off) {
|
|
126
137
|
off = 0
|
|
138
|
+
}
|
|
127
139
|
|
|
128
|
-
if (!(buf.length >= off + 512))
|
|
140
|
+
if (!(buf.length >= off + 512)) {
|
|
129
141
|
throw new Error('need 512 bytes for header')
|
|
142
|
+
}
|
|
130
143
|
|
|
131
144
|
const prefixSize = this.ctime || this.atime ? 130 : 155
|
|
132
145
|
const split = splitPrefix(this.path || '', prefixSize)
|
|
@@ -148,20 +161,22 @@ class Header {
|
|
|
148
161
|
this.needPax = encNumber(buf, off + 329, 8, this.devmaj) || this.needPax
|
|
149
162
|
this.needPax = encNumber(buf, off + 337, 8, this.devmin) || this.needPax
|
|
150
163
|
this.needPax = encString(buf, off + 345, prefixSize, prefix) || this.needPax
|
|
151
|
-
if (buf[off + 475] !== 0)
|
|
164
|
+
if (buf[off + 475] !== 0) {
|
|
152
165
|
this.needPax = encString(buf, off + 345, 155, prefix) || this.needPax
|
|
153
|
-
else {
|
|
166
|
+
} else {
|
|
154
167
|
this.needPax = encString(buf, off + 345, 130, prefix) || this.needPax
|
|
155
168
|
this.needPax = encDate(buf, off + 476, 12, this.atime) || this.needPax
|
|
156
169
|
this.needPax = encDate(buf, off + 488, 12, this.ctime) || this.needPax
|
|
157
170
|
}
|
|
158
171
|
|
|
159
172
|
let sum = 8 * 0x20
|
|
160
|
-
for (let i = off; i < off + 148; i++)
|
|
173
|
+
for (let i = off; i < off + 148; i++) {
|
|
161
174
|
sum += buf[i]
|
|
175
|
+
}
|
|
162
176
|
|
|
163
|
-
for (let i = off + 156; i < off + 512; i++)
|
|
177
|
+
for (let i = off + 156; i < off + 512; i++) {
|
|
164
178
|
sum += buf[i]
|
|
179
|
+
}
|
|
165
180
|
|
|
166
181
|
this.cksum = sum
|
|
167
182
|
encNumber(buf, off + 148, 8, this.cksum)
|
|
@@ -172,8 +187,9 @@ class Header {
|
|
|
172
187
|
|
|
173
188
|
set (data) {
|
|
174
189
|
for (const i in data) {
|
|
175
|
-
if (data[i] !== null && data[i] !== undefined)
|
|
190
|
+
if (data[i] !== null && data[i] !== undefined) {
|
|
176
191
|
this[i] = data[i]
|
|
192
|
+
}
|
|
177
193
|
}
|
|
178
194
|
}
|
|
179
195
|
|
|
@@ -186,10 +202,11 @@ class Header {
|
|
|
186
202
|
}
|
|
187
203
|
|
|
188
204
|
set type (type) {
|
|
189
|
-
if (types.code.has(type))
|
|
205
|
+
if (types.code.has(type)) {
|
|
190
206
|
this[TYPE] = types.code.get(type)
|
|
191
|
-
else
|
|
207
|
+
} else {
|
|
192
208
|
this[TYPE] = type
|
|
209
|
+
}
|
|
193
210
|
}
|
|
194
211
|
}
|
|
195
212
|
|
|
@@ -200,25 +217,23 @@ const splitPrefix = (p, prefixSize) => {
|
|
|
200
217
|
let ret
|
|
201
218
|
const root = pathModule.parse(p).root || '.'
|
|
202
219
|
|
|
203
|
-
if (Buffer.byteLength(pp) < pathSize)
|
|
220
|
+
if (Buffer.byteLength(pp) < pathSize) {
|
|
204
221
|
ret = [pp, prefix, false]
|
|
205
|
-
else {
|
|
222
|
+
} else {
|
|
206
223
|
// first set prefix to the dir, and path to the base
|
|
207
224
|
prefix = pathModule.dirname(pp)
|
|
208
225
|
pp = pathModule.basename(pp)
|
|
209
226
|
|
|
210
227
|
do {
|
|
211
|
-
// both fit!
|
|
212
228
|
if (Buffer.byteLength(pp) <= pathSize &&
|
|
213
|
-
Buffer.byteLength(prefix) <= prefixSize)
|
|
229
|
+
Buffer.byteLength(prefix) <= prefixSize) {
|
|
230
|
+
// both fit!
|
|
214
231
|
ret = [pp, prefix, false]
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
else {
|
|
232
|
+
} else if (Buffer.byteLength(pp) > pathSize &&
|
|
233
|
+
Buffer.byteLength(prefix) <= prefixSize) {
|
|
234
|
+
// prefix fits in prefix, but path doesn't fit in path
|
|
235
|
+
ret = [pp.slice(0, pathSize - 1), prefix, true]
|
|
236
|
+
} else {
|
|
222
237
|
// make path take a bit from prefix
|
|
223
238
|
pp = pathModule.join(pathModule.basename(prefix), pp)
|
|
224
239
|
prefix = pathModule.dirname(prefix)
|
|
@@ -226,8 +241,9 @@ const splitPrefix = (p, prefixSize) => {
|
|
|
226
241
|
} while (prefix !== root && !ret)
|
|
227
242
|
|
|
228
243
|
// at this point, found no resolution, just truncate
|
|
229
|
-
if (!ret)
|
|
230
|
-
ret = [p.
|
|
244
|
+
if (!ret) {
|
|
245
|
+
ret = [p.slice(0, pathSize - 1), '', true]
|
|
246
|
+
}
|
|
231
247
|
}
|
|
232
248
|
return ret
|
|
233
249
|
}
|
|
@@ -3,14 +3,15 @@
|
|
|
3
3
|
// 0xff for negative, and 0x80 for positive.
|
|
4
4
|
|
|
5
5
|
const encode = (num, buf) => {
|
|
6
|
-
if (!Number.isSafeInteger(num))
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
if (!Number.isSafeInteger(num)) {
|
|
7
|
+
// The number is so large that javascript cannot represent it with integer
|
|
8
|
+
// precision.
|
|
9
9
|
throw Error('cannot encode number outside of javascript safe integer range')
|
|
10
|
-
else if (num < 0)
|
|
10
|
+
} else if (num < 0) {
|
|
11
11
|
encodeNegative(num, buf)
|
|
12
|
-
else
|
|
12
|
+
} else {
|
|
13
13
|
encodePositive(num, buf)
|
|
14
|
+
}
|
|
14
15
|
return buf
|
|
15
16
|
}
|
|
16
17
|
|
|
@@ -30,11 +31,11 @@ const encodeNegative = (num, buf) => {
|
|
|
30
31
|
for (var i = buf.length; i > 1; i--) {
|
|
31
32
|
var byte = num & 0xff
|
|
32
33
|
num = Math.floor(num / 0x100)
|
|
33
|
-
if (flipped)
|
|
34
|
+
if (flipped) {
|
|
34
35
|
buf[i - 1] = onesComp(byte)
|
|
35
|
-
else if (byte === 0)
|
|
36
|
+
} else if (byte === 0) {
|
|
36
37
|
buf[i - 1] = 0
|
|
37
|
-
else {
|
|
38
|
+
} else {
|
|
38
39
|
flipped = true
|
|
39
40
|
buf[i - 1] = twosComp(byte)
|
|
40
41
|
}
|
|
@@ -46,13 +47,15 @@ const parse = (buf) => {
|
|
|
46
47
|
const value = pre === 0x80 ? pos(buf.slice(1, buf.length))
|
|
47
48
|
: pre === 0xff ? twos(buf)
|
|
48
49
|
: null
|
|
49
|
-
if (value === null)
|
|
50
|
+
if (value === null) {
|
|
50
51
|
throw Error('invalid base256 encoding')
|
|
52
|
+
}
|
|
51
53
|
|
|
52
|
-
if (!Number.isSafeInteger(value))
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
if (!Number.isSafeInteger(value)) {
|
|
55
|
+
// The number is so large that javascript cannot represent it with integer
|
|
56
|
+
// precision.
|
|
55
57
|
throw Error('parsed number outside of javascript safe integer range')
|
|
58
|
+
}
|
|
56
59
|
|
|
57
60
|
return value
|
|
58
61
|
}
|
|
@@ -64,16 +67,17 @@ const twos = (buf) => {
|
|
|
64
67
|
for (var i = len - 1; i > -1; i--) {
|
|
65
68
|
var byte = buf[i]
|
|
66
69
|
var f
|
|
67
|
-
if (flipped)
|
|
70
|
+
if (flipped) {
|
|
68
71
|
f = onesComp(byte)
|
|
69
|
-
else if (byte === 0)
|
|
72
|
+
} else if (byte === 0) {
|
|
70
73
|
f = byte
|
|
71
|
-
else {
|
|
74
|
+
} else {
|
|
72
75
|
flipped = true
|
|
73
76
|
f = twosComp(byte)
|
|
74
77
|
}
|
|
75
|
-
if (f !== 0)
|
|
78
|
+
if (f !== 0) {
|
|
76
79
|
sum -= f * Math.pow(256, len - i - 1)
|
|
80
|
+
}
|
|
77
81
|
}
|
|
78
82
|
return sum
|
|
79
83
|
}
|
|
@@ -83,8 +87,9 @@ const pos = (buf) => {
|
|
|
83
87
|
var sum = 0
|
|
84
88
|
for (var i = len - 1; i > -1; i--) {
|
|
85
89
|
var byte = buf[i]
|
|
86
|
-
if (byte !== 0)
|
|
90
|
+
if (byte !== 0) {
|
|
87
91
|
sum += byte * Math.pow(256, len - i - 1)
|
|
92
|
+
}
|
|
88
93
|
}
|
|
89
94
|
return sum
|
|
90
95
|
}
|