1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2026-01-06 18:43:46 +00:00

Updated zip-writer so you can pass folder names

This commit is contained in:
Bryan Roe
2020-06-24 01:59:01 -07:00
parent f97ebdbdd4
commit 33035ea5e3
2 changed files with 35 additions and 1 deletions

File diff suppressed because one or more lines are too long

View File

@@ -180,9 +180,43 @@ function next(options)
require('fs').read(this._currentFD, { buffer: this._ubuffer }, this._uncompressedReadSink);
}
function checkFiles(files)
{
var checked = [];
var tmp;
var s, j;
for(var i in files)
{
s = require('fs').statSync(files[i]);
if(s.isFile())
{
checked.push(files[i]);
}
else if (s.isDirectory())
{
tmp = require('fs').readdirSync(files[i]);
for (j in tmp)
{
tmp[j] = files[i] + (process.platform == 'win32' ? '\\' : '/') + tmp[j];
}
tmp = checkFiles(tmp);
for(j in tmp)
{
checked.push(tmp[j]);
}
}
}
return (checked);
}
function write(options)
{
if (!options.files || options.files.length == 0) { throw ('No file specified'); }
// Check if any folders were specified
options.files = checkFiles(options.files);
var ret = new duplex(
{
write: function (chunk, flush)