rafale
Version:
Deploy every services, everywhere, in just a few seconds
1 lines • 4.04 kB
JavaScript
var Utils=require("../util"),Constants=Utils.Constants;module.exports=function(){function t(t){var t=new Date(t);r=(t.getFullYear()-1980&127)<<25|t.getMonth()+1<<21|t.getDay()<<16|t.getHours()<<11|t.getMinutes()<<5|t.getSeconds()>>1}var n=10,e=10,s=0,o=0,r=0,C=0,a=0,c=0,E=0,i=0,L=0,b=0,u=0,j=0,I=0,O={};return t(+new Date),{get made(){return n},set made(t){n=t},get version(){return e},set version(t){e=t},get flags(){return s},set flags(t){s=t},get method(){return o},set method(t){o=t},get time(){return new Date((r>>25&127)+1980,(r>>21&15)-1,r>>16&31,r>>11&31,r>>5&63,(31&r)<<1)},set time(n){t(n)},get crc(){return C},set crc(t){C=t},get compressedSize(){return a},set compressedSize(t){a=t},get size(){return c},set size(t){c=t},get fileNameLength(){return E},set fileNameLength(t){E=t},get extraLength(){return i},set extraLength(t){i=t},get commentLength(){return L},set commentLength(t){L=t},get diskNumStart(){return b},set diskNumStart(t){b=t},get inAttr(){return u},set inAttr(t){u=t},get attr(){return j},set attr(t){j=t},get offset(){return I},set offset(t){I=t},get encripted(){return 1==(1&s)},get entryHeaderSize(){return Constants.CENHDR+E+i+L},get realDataOffset(){return I+Constants.LOCHDR+O.fnameLen+O.extraLen},get dataHeader(){return O},loadDataHeaderFromBinary:function(t){var n=t.slice(I,I+Constants.LOCHDR);if(n.readUInt32LE(0)!=Constants.LOCSIG)throw Utils.Errors.INVALID_LOC;O={version:n.readUInt16LE(Constants.LOCVER),flags:n.readUInt16LE(Constants.LOCFLG),method:n.readUInt16LE(Constants.LOCHOW),time:n.readUInt32LE(Constants.LOCTIM),crc:n.readUInt32LE(Constants.LOCCRC),compressedSize:n.readUInt32LE(Constants.LOCSIZ),size:n.readUInt32LE(Constants.LOCLEN),fnameLen:n.readUInt16LE(Constants.LOCNAM),extraLen:n.readUInt16LE(Constants.LOCEXT)}},loadFromBinary:function(t){if(t.length!=Constants.CENHDR||t.readUInt32LE(0)!=Constants.CENSIG)throw Utils.Errors.INVALID_CEN;n=t.readUInt16LE(Constants.CENVEM),e=t.readUInt16LE(Constants.CENVER),s=t.readUInt16LE(Constants.CENFLG),o=t.readUInt16LE(Constants.CENHOW),r=t.readUInt32LE(Constants.CENTIM),C=t.readUInt32LE(Constants.CENCRC),a=t.readUInt32LE(Constants.CENSIZ),c=t.readUInt32LE(Constants.CENLEN),E=t.readUInt16LE(Constants.CENNAM),i=t.readUInt16LE(Constants.CENEXT),L=t.readUInt16LE(Constants.CENCOM),b=t.readUInt16LE(Constants.CENDSK),u=t.readUInt16LE(Constants.CENATT),j=t.readUInt32LE(Constants.CENATX),I=t.readUInt32LE(Constants.CENOFF)},dataHeaderToBinary:function(){var t=new Buffer(Constants.LOCHDR);return t.writeUInt32LE(Constants.LOCSIG,0),t.writeUInt16LE(e,Constants.LOCVER),t.writeUInt16LE(s,Constants.LOCFLG),t.writeUInt16LE(o,Constants.LOCHOW),t.writeUInt32LE(r,Constants.LOCTIM),t.writeUInt32LE(C,Constants.LOCCRC),t.writeUInt32LE(a,Constants.LOCSIZ),t.writeUInt32LE(c,Constants.LOCLEN),t.writeUInt16LE(E,Constants.LOCNAM),t.writeUInt16LE(i,Constants.LOCEXT),t},entryHeaderToBinary:function(){var t=new Buffer(Constants.CENHDR+E+i+L);return t.writeUInt32LE(Constants.CENSIG,0),t.writeUInt16LE(n,Constants.CENVEM),t.writeUInt16LE(e,Constants.CENVER),t.writeUInt16LE(s,Constants.CENFLG),t.writeUInt16LE(o,Constants.CENHOW),t.writeUInt32LE(r,Constants.CENTIM),t.writeInt32LE(C,Constants.CENCRC,!0),t.writeUInt32LE(a,Constants.CENSIZ),t.writeUInt32LE(c,Constants.CENLEN),t.writeUInt16LE(E,Constants.CENNAM),t.writeUInt16LE(i,Constants.CENEXT),t.writeUInt16LE(L,Constants.CENCOM),t.writeUInt16LE(b,Constants.CENDSK),t.writeUInt16LE(u,Constants.CENATT),t.writeUInt32LE(j,Constants.CENATX),t.writeUInt32LE(I,Constants.CENOFF),t.fill(0,Constants.CENHDR),t},toString:function(){return'{\n "made" : '+n+',\n "version" : '+e+',\n "flags" : '+s+',\n "method" : '+Utils.methodToString(o)+',\n "time" : '+r+',\n "crc" : 0x'+C.toString(16).toUpperCase()+',\n "compressedSize" : '+a+' bytes,\n "size" : '+c+' bytes,\n "fileNameLength" : '+E+',\n "extraLength" : '+i+' bytes,\n "commentLength" : '+L+' bytes,\n "diskNumStart" : '+b+',\n "inAttr" : '+u+',\n "attr" : '+j+',\n "offset" : '+I+',\n "entryHeaderSize" : '+(Constants.CENHDR+E+i+L)+" bytes\n}"}}};