1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-10 21:33:38 +00:00

1. Updated fs.readSync

2. Added zip-reader.isZip()
3. Added support for zip compressed selfupdate
This commit is contained in:
Bryan Roe
2020-07-10 01:01:27 -07:00
parent c390676809
commit f9c9e4264d
4 changed files with 131 additions and 39 deletions

View File

@@ -438,4 +438,19 @@ function read(path)
return(ret);
}
module.exports = { read: read };
function isZip(path)
{
if (require('fs').statSync(path).size < 30) { return (false); }
var fd = require('fs').openSync(path, 'rb');
var jsFile = Buffer.alloc(4);
var bytesRead = require('fs').readSync(fd, jsFile, { position: 0 });
require('fs').closeSync(fd);
if (bytesRead == 4 && jsFile[0] == 0x50 && jsFile[1] == 0x4B && jsFile[2] == 0x03 && jsFile[3] == 0x04)
{
return (true);
}
return (false);
}
module.exports = { read: read, isZip: isZip };