@yarnpkg/libzip
Advanced tools
Comparing version 3.0.0-rc.35 to 3.0.0-rc.36
@@ -11,5 +11,3 @@ /// <reference types="emscripten" /> | ||
readonly ZIP_CHECKCONS: 4; | ||
readonly ZIP_CREATE: 1; | ||
readonly ZIP_EXCL: 2; | ||
readonly ZIP_TRUNCATE: 8; | ||
readonly ZIP_RDONLY: 16; | ||
@@ -48,3 +46,2 @@ readonly ZIP_FL_OVERWRITE: 8192; | ||
readonly getValue: typeof getValue; | ||
readonly open: (arg_0: string, arg_1: number, arg_2: number) => number; | ||
readonly openFromSource: (arg_0: number, arg_1: number, arg_2: number) => number; | ||
@@ -120,5 +117,3 @@ readonly close: (arg_0: number) => number; | ||
readonly ZIP_CHECKCONS: 4; | ||
readonly ZIP_CREATE: 1; | ||
readonly ZIP_EXCL: 2; | ||
readonly ZIP_TRUNCATE: 8; | ||
readonly ZIP_RDONLY: 16; | ||
@@ -157,3 +152,2 @@ readonly ZIP_FL_OVERWRITE: 8192; | ||
readonly getValue: typeof getValue; | ||
readonly open: (arg_0: string, arg_1: number, arg_2: number) => number; | ||
readonly openFromSource: (arg_0: number, arg_1: number, arg_2: number) => number; | ||
@@ -160,0 +154,0 @@ readonly close: (arg_0: number) => number; |
@@ -13,5 +13,3 @@ /// <reference types="emscripten" /> | ||
readonly ZIP_CHECKCONS: 4; | ||
readonly ZIP_CREATE: 1; | ||
readonly ZIP_EXCL: 2; | ||
readonly ZIP_TRUNCATE: 8; | ||
readonly ZIP_RDONLY: 16; | ||
@@ -50,3 +48,2 @@ readonly ZIP_FL_OVERWRITE: 8192; | ||
readonly getValue: typeof getValue; | ||
readonly open: (arg_0: string, arg_1: number, arg_2: number) => number; | ||
readonly openFromSource: (arg_0: number, arg_1: number, arg_2: number) => number; | ||
@@ -122,5 +119,3 @@ readonly close: (arg_0: number) => number; | ||
readonly ZIP_CHECKCONS: 4; | ||
readonly ZIP_CREATE: 1; | ||
readonly ZIP_EXCL: 2; | ||
readonly ZIP_TRUNCATE: 8; | ||
readonly ZIP_RDONLY: 16; | ||
@@ -159,3 +154,2 @@ readonly ZIP_FL_OVERWRITE: 8192; | ||
readonly getValue: typeof getValue; | ||
readonly open: (arg_0: string, arg_1: number, arg_2: number) => number; | ||
readonly openFromSource: (arg_0: number, arg_1: number, arg_2: number) => number; | ||
@@ -162,0 +156,0 @@ readonly close: (arg_0: number) => number; |
@@ -46,5 +46,3 @@ /// <reference types="emscripten" /> | ||
readonly ZIP_CHECKCONS: 4; | ||
readonly ZIP_CREATE: 1; | ||
readonly ZIP_EXCL: 2; | ||
readonly ZIP_TRUNCATE: 8; | ||
readonly ZIP_RDONLY: 16; | ||
@@ -83,3 +81,2 @@ readonly ZIP_FL_OVERWRITE: 8192; | ||
readonly getValue: typeof getValue; | ||
readonly open: (arg_0: string, arg_1: number, arg_2: number) => number; | ||
readonly openFromSource: (arg_0: number, arg_1: number, arg_2: number) => number; | ||
@@ -86,0 +83,0 @@ readonly close: (arg_0: number) => number; |
@@ -56,5 +56,3 @@ "use strict"; | ||
ZIP_CHECKCONS: 4, | ||
ZIP_CREATE: 1, | ||
ZIP_EXCL: 2, | ||
ZIP_TRUNCATE: 8, | ||
ZIP_RDONLY: 16, | ||
@@ -93,3 +91,2 @@ ZIP_FL_OVERWRITE: 8192, | ||
getValue: emZip.getValue, | ||
open: emZip.cwrap(`zip_open`, `number`, [`string`, `number`, `number`]), | ||
openFromSource: emZip.cwrap(`zip_open_from_source`, `number`, [`number`, `number`, `number`]), | ||
@@ -96,0 +93,0 @@ close: emZip.cwrap(`zip_close`, `number`, [`number`]), |
@@ -11,5 +11,3 @@ /// <reference types="emscripten" /> | ||
readonly ZIP_CHECKCONS: 4; | ||
readonly ZIP_CREATE: 1; | ||
readonly ZIP_EXCL: 2; | ||
readonly ZIP_TRUNCATE: 8; | ||
readonly ZIP_RDONLY: 16; | ||
@@ -48,3 +46,2 @@ readonly ZIP_FL_OVERWRITE: 8192; | ||
readonly getValue: typeof getValue; | ||
readonly open: (arg_0: string, arg_1: number, arg_2: number) => number; | ||
readonly openFromSource: (arg_0: number, arg_1: number, arg_2: number) => number; | ||
@@ -120,5 +117,3 @@ readonly close: (arg_0: number) => number; | ||
readonly ZIP_CHECKCONS: 4; | ||
readonly ZIP_CREATE: 1; | ||
readonly ZIP_EXCL: 2; | ||
readonly ZIP_TRUNCATE: 8; | ||
readonly ZIP_RDONLY: 16; | ||
@@ -157,3 +152,2 @@ readonly ZIP_FL_OVERWRITE: 8192; | ||
readonly getValue: typeof getValue; | ||
readonly open: (arg_0: string, arg_1: number, arg_2: number) => number; | ||
readonly openFromSource: (arg_0: number, arg_1: number, arg_2: number) => number; | ||
@@ -160,0 +154,0 @@ readonly close: (arg_0: number) => number; |
@@ -58,6 +58,6 @@ /// <reference types="node" /> | ||
getRealPath(): PortablePath; | ||
private prepareClose; | ||
getBufferAndClose(): Buffer; | ||
private prepareClose; | ||
discardAndClose(): void; | ||
saveAndClose(): void; | ||
discardAndClose(): void; | ||
resolve(p: PortablePath): PortablePath; | ||
@@ -64,0 +64,0 @@ openPromise(p: PortablePath, flags: string, mode?: number): Promise<number>; |
@@ -55,3 +55,2 @@ "use strict"; | ||
super(); | ||
this.lzSource = null; | ||
this.listings = new Map(); | ||
@@ -108,4 +107,2 @@ this.entries = new Map(); | ||
let flags = 0; | ||
if (typeof source === `string` && pathOptions.create) | ||
flags |= this.libzip.ZIP_CREATE | this.libzip.ZIP_TRUNCATE; | ||
if (opts.readOnly) { | ||
@@ -115,15 +112,14 @@ flags |= this.libzip.ZIP_RDONLY; | ||
} | ||
if (typeof source === `string`) { | ||
this.zip = this.libzip.open(fslib_6.npath.fromPortablePath(source), flags, errPtr); | ||
if (typeof source === `string`) | ||
source = pathOptions.create | ||
? makeEmptyArchive() | ||
: this.baseFs.readFileSync(source); | ||
const lzSource = this.allocateUnattachedSource(source); | ||
try { | ||
this.zip = this.libzip.openFromSource(lzSource, flags, errPtr); | ||
this.lzSource = lzSource; | ||
} | ||
else { | ||
const lzSource = this.allocateUnattachedSource(source); | ||
try { | ||
this.zip = this.libzip.openFromSource(lzSource, flags, errPtr); | ||
this.lzSource = lzSource; | ||
} | ||
catch (error) { | ||
this.libzip.source.free(lzSource); | ||
throw error; | ||
} | ||
catch (error) { | ||
this.libzip.source.free(lzSource); | ||
throw error; | ||
} | ||
@@ -184,6 +180,9 @@ if (this.zip === 0) { | ||
} | ||
prepareClose() { | ||
if (!this.ready) | ||
throw fslib_5.errors.EBUSY(`archive closed, close`); | ||
(0, fslib_4.unwatchAllFiles)(this); | ||
} | ||
getBufferAndClose() { | ||
this.prepareClose(); | ||
if (!this.lzSource) | ||
throw new Error(`ZipFS was not created from a Buffer`); | ||
// zip_source_open on an unlink-after-write empty archive fails with "Entry has been deleted" | ||
@@ -237,6 +236,6 @@ if (this.entries.size === 0) { | ||
} | ||
prepareClose() { | ||
if (!this.ready) | ||
throw fslib_5.errors.EBUSY(`archive closed, close`); | ||
(0, fslib_4.unwatchAllFiles)(this); | ||
discardAndClose() { | ||
this.prepareClose(); | ||
this.libzip.discard(this.zip); | ||
this.ready = false; | ||
} | ||
@@ -246,3 +245,2 @@ saveAndClose() { | ||
throw new Error(`ZipFS cannot be saved and must be discarded when loaded from a buffer`); | ||
this.prepareClose(); | ||
if (this.readOnly) { | ||
@@ -255,22 +253,5 @@ this.discardAndClose(); | ||
: this.stats.mode; | ||
// zip_close doesn't persist empty archives | ||
if (this.entries.size === 0) { | ||
this.discardAndClose(); | ||
this.baseFs.writeFileSync(this.path, makeEmptyArchive(), { mode: newMode }); | ||
} | ||
else { | ||
const rc = this.libzip.close(this.zip); | ||
if (rc === -1) | ||
throw this.makeLibzipError(this.libzip.getError(this.zip)); | ||
if (typeof newMode !== `undefined`) { | ||
this.baseFs.chmodSync(this.path, newMode); | ||
} | ||
} | ||
this.baseFs.writeFileSync(this.path, this.getBufferAndClose(), { mode: newMode }); | ||
this.ready = false; | ||
} | ||
discardAndClose() { | ||
this.prepareClose(); | ||
this.libzip.discard(this.zip); | ||
this.ready = false; | ||
} | ||
resolve(p) { | ||
@@ -277,0 +258,0 @@ return fslib_6.ppath.resolve(fslib_6.PortablePath.root, p); |
{ | ||
"name": "@yarnpkg/libzip", | ||
"version": "3.0.0-rc.35", | ||
"version": "3.0.0-rc.36", | ||
"license": "BSD-2-Clause", | ||
@@ -45,7 +45,7 @@ "main": "./lib/sync.js", | ||
"@types/emscripten": "^1.39.6", | ||
"@yarnpkg/fslib": "^3.0.0-rc.35", | ||
"@yarnpkg/fslib": "^3.0.0-rc.36", | ||
"tslib": "^2.4.0" | ||
}, | ||
"peerDependencies": { | ||
"@yarnpkg/fslib": "^3.0.0-rc.35" | ||
"@yarnpkg/fslib": "^3.0.0-rc.36" | ||
}, | ||
@@ -52,0 +52,0 @@ "engines": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
533343
5754
Updated@yarnpkg/fslib@^3.0.0-rc.36