1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-13 14:53:46 +00:00

Improved zip-reader to better support relative paths

This commit is contained in:
Bryan Roe
2020-06-24 13:58:56 -07:00
parent 33035ea5e3
commit ac1da9725d
2 changed files with 12 additions and 2 deletions

File diff suppressed because one or more lines are too long

View File

@@ -37,7 +37,7 @@ function checkFolderPath(dest)
} }
function extractNext(p) function extractNext(p)
{ {
if (p.pending.length == 0) { p._res(); return; } if (p.pending.length == 0) { p.source.close(); p._res(); return; }
var next = p.pending.pop(); var next = p.pending.pop();
var dest = p.baseFolder + (process.platform == 'win32' ? '\\' : '/') + next; var dest = p.baseFolder + (process.platform == 'win32' ? '\\' : '/') + next;
if (process.platform == 'win32') { dest = dest.split('/').join('\\'); } if (process.platform == 'win32') { dest = dest.split('/').join('\\'); }
@@ -48,6 +48,7 @@ function extractNext(p)
} }
catch(e) catch(e)
{ {
p.source.close();
p._rej(e); p._rej(e);
return; return;
} }
@@ -226,6 +227,15 @@ function zippedObject(table)
}; };
this.extractAll = function extractAll(destFolder) this.extractAll = function extractAll(destFolder)
{ {
if (process.platform == 'win32')
{
if (!destFolder.includes(':\\')) { destFolder = process.cwd() + destFolder; }
}
else
{
if (!destFolder.startsWith('/')) { destFolder = process.cwd() + destFolder; }
}
var i; var i;
var ret = new promise(function (res, rej) { this._res = res; this._rej = rej; }); var ret = new promise(function (res, rej) { this._res = res; this._rej = rej; });
if (destFolder.endsWith(process.platform == 'win32' ? '\\' : '/')) { destFolder = destFolder.substring(0, destFolder.length - 1); } if (destFolder.endsWith(process.platform == 'win32' ? '\\' : '/')) { destFolder = destFolder.substring(0, destFolder.length - 1); }