File "rar.js"

Full Path: /home/warrior1/public_html/wp-content-20241001222009/plugins/file-manager/libs/elFinder/js/cdn/rar.js
File size: 9.39 KB
MIME-type: text/plain
Charset: utf-8

(function(){var d=function(e){this.type=e||d.OPEN_URI;this.size=null;this.file=null;this.abort=null;this.buffer=null;this.bufferStart=0;this.getSize=128*1024};d.OPEN_FILE=1;d.OPEN_URI=2;d.OPEN_LOCAL=3;if(typeof require==="function"&&typeof process!=="undefined"){var a=require("fs")}d.prototype.open=function(f,g){this.file=f;var e=this;switch(this.type){case d.OPEN_LOCAL:a.stat(this.file,function(i,h){if(i){return g(i)}e.size=h.size;a.open(e.file,"r",function(k,j){if(k){return g(k)}e.fd=j;g()})});break;case d.OPEN_FILE:this.size=this.file.size;g();break;default:this.ajax({uri:this.file,type:"HEAD"},function(h,j,i){if(h){return g(h)}e.size=parseInt(i.getResponseHeader("Content-Length"));g()});break}};d.prototype.close=function(){if(this.type===d.OPEN_LOCAL){a.close(this.fd)}};d.prototype.read=function(f,e,g){if(this.type===d.OPEN_LOCAL){this.readLocal(f,e,g)}else{if(this.type===d.OPEN_FILE){this.readFile(f,e,g)}else{this.readUri(f,e,g)}}};d.prototype.readBlob=function(g,e,f,h){if(typeof f==="function"){h=f;f="application/octet-stream"}this.read(g,e,function(i,j){if(i){h(i);return}h(null,new Blob([j],{type:f}))})};d.prototype.readLocal=function(g,e,h){var f=new Buffer(g);a.read(this.fd,f,0,g,e,function(m,o,k){if(m){return h(m)}var n=new ArrayBuffer(k.length),j=new Uint8Array(n);for(var l=0;l<k.length;l++){j[l]=k[l]}h(null,n)})};d.prototype.ajax=function(h,j){var f={type:"GET",uri:null,responseType:"text"},g;if(typeof h==="string"){h={uri:h}}for(var e in h){f[e]=h[e]}if(f.type.toLowerCase()==="get"&&f.range){f.uri+=(f.uri.match(/\?/)?"&":"?")+"_="+(+new Date())}var i=new XMLHttpRequest();i.onreadystatechange=function(){if(i.readyState!==4){return}if(i.status!==200&&i.status!==206){return j("Received non-200/206 response ("+i.status+")")}j(null,i.response,i)};i.responseType=f.responseType;i.open(f.type,f.uri,true);if(f.range){f.range=[].concat(f.range);if(f.range.length===2){i.setRequestHeader("Range","bytes="+f.range[0]+"-"+f.range[1])}else{i.setRequestHeader("Range","bytes="+f.range[0])}}if(this.options.xhrHeaders){for(g in this.options.xhrHeaders){if(this.options.xhrHeaders.hasOwnProperty(g)){i.setRequestHeader(g,this.options.xhrHeaders[g])}}}if(this.options.xhrFields){for(g in this.options.xhrFields){if(this.options.xhrFields.hasOwnProperty(g)){if(g in i){i[g]=this.options.xhrFields[g]}}}}i.send()};d.prototype.readUri=function(f,h,l){var m=this,e,g=Math.min(h+f,m.size),j=!m.buffer?0:m.bufferStart+m.buffer.byteLength,n=m.options.xhrGetSize||m.getSize,k,i=function(p){var o=0,q,r,s;for(q=0;q<p.length;++q){o+=p[q].byteLength}r=new Uint8Array(o);s=0;for(q=0;q<p.length;++q){r.set(new Uint8Array(p[q]),s);s+=p[q].byteLength}return r.buffer};if(j<g){if(h>j){j=h}else{if(m.buffer&&h<=j){k=m.buffer.slice((j-h)*-1)}}m.ajax({uri:m.file,type:"GET",responseType:"arraybuffer",range:[j,Math.min(m.size-1,j+Math.max(n,f)-1)]},function(p,o){if(p){return l(p)}m.bufferStart=j;if(k){m.buffer=i([k,o]);m.bufferStart-=k.byteLength}else{m.buffer=o}e=h-m.bufferStart;return l(null,m.buffer.slice(e,e+f))})}else{e=h-m.bufferStart;l(null,m.buffer.slice(e,e+f))}};d.prototype.readFile=function(g,e,i){var h=this.file.slice(e,e+g),f=new FileReader();f.onload=function(j){i(null,j.target.result)};f.onerror=function(j){i("File read failed")};f.readAsArrayBuffer(h)};DataView.prototype.getString=function(h,m,f){m=m||0;h=h||(this.byteLength-m);if(h<0){h+=this.byteLength}var l="";if(typeof Buffer!=="undefined"){var j=[];for(var g=m;g<(m+h);g++){j.push(this.getUint8(g))}return(new Buffer(j)).toString()}else{for(var g=m;g<(m+h);g++){l+=String.fromCharCode(this.getUint8(g))}if(f){return l}try{return decodeURIComponent(escape(l))}catch(k){return l}}};DataView.prototype.getStringUtf16=function(h,k,p){k=k||0;h=h||(this.byteLength-k);var g=false,o="",j=false;if(typeof Buffer!=="undefined"){o=[];j=true}if(h<0){h+=this.byteLength}if(p){var m=this.getUint16(k);if(m===65534){g=true}k+=2;h-=2}for(var l=k;l<(k+h);l+=2){var f=this.getUint16(l,g);if((f>=0&&f<=55295)||(f>=57344&&f<=65535)){if(j){o.push(f)}else{o+=String.fromCharCode(f)}}else{if(f>=65536&&f<=1114111){f-=65536;if(j){o.push(((1047552&f)>>10)+55296);o.push((1023&f)+56320)}else{o+=String.fromCharCode(((1047552&f)>>10)+55296)+String.fromCharCode((1023&f)+56320)}}}}if(j){return(new Buffer(o)).toString()}else{try{return decodeURIComponent(escape(o))}catch(n){return o}}};DataView.prototype.getSynch=function(g){var f=0,e=2130706432;while(e){f>>=1;f|=g&e;e>>=8}return f};DataView.prototype.getUint8Synch=function(e){return this.getSynch(this.getUint8(e))};DataView.prototype.getUint32Synch=function(e){return this.getSynch(this.getUint32(e))};DataView.prototype.getUint24=function(f,e){if(e){return this.getUint8(f)+(this.getUint8(f+1)<<8)+(this.getUint8(f+2)<<16)}return this.getUint8(f+2)+(this.getUint8(f+1)<<8)+(this.getUint8(f)<<16)};var b=function(){this.name=null;this.path=null;this.size=0;this.sizePacked=0;this.crc=null;this.offset=0;this.blockSize=0;this.headerSize=0;this.encrypted=false;this.version=null;this.time=null;this.method=null;this.os=null;this.partial=false;this.continuesFrom=false;this.continues=false};b.METHOD_STORE=48;b.METHOD_FASTEST=49;b.METHOD_FAST=50;b.METHOD_NORMAL=51;b.METHOD_GOOD=52;b.METHOD_BEST=53;var c=function(){if(!(this instanceof c)){return new c(arguments[0],arguments[1])}this.options={type:c.OPEN_URI};var f=arguments[0];if(typeof f==="string"){f={file:f,type:c.OPEN_URI}}else{if(typeof window!=="undefined"&&window.File&&f instanceof window.File){f={file:f,type:c.OPEN_FILE}}}for(var e in f){if(f.hasOwnProperty(e)){this.options[e]=f[e]}}if(!this.options.file){if(arguments[1]){arguments[1].call(this,"No file was set")}return}if(this.options.type===c.OPEN_FILE){if(typeof window==="undefined"||!window.File||!window.FileReader||typeof ArrayBuffer==="undefined"){if(arguments[1]){arguments[1].call(this,"Browser does not have support for the File API and/or ArrayBuffers")}}}else{if(this.options.type===c.OPEN_LOCAL){if(typeof require!=="function"){if(arguments[1]){arguments[1].call(this,"Local paths may not be read within a browser")}return}}else{}}this.file=this.options.file;this.rd=new d(this.options.type);this.rd.options=this.options;this.entries=[];this.valid=false;this.validate(arguments[1])};c.prototype.validate=function(f){var e=this;this.rd.open(this.file,function(g){if(g){if(f){f.call(e,g)}return}e.rd.read(14,0,function(l,n){if(l){if(f){f.call(e,l)}return}var i=new DataView(n);if(i.getString(7,0,true)!=="\x52\x61\x72\x21\x1a\x07\x00"){if(f){f.call(e,"Invalid RAR archive")}return}var m=i.getUint16(7,true),k=i.getUint8(9),h=i.getUint16(10,true),j=i.getUint16(12,true);if(k!==115){if(f){f.call(e,"Invalid RAR archive")}return}if((h&128)!==0){if(f){f.call(e,"Encrypted RAR archives are not yet supported")}return}e.valid=true;e.readHeaders(j+7,f)})})};c.prototype.parseEntry=function(f,g){var e=this;this.rd.read(11,f,function(k,l){if(k){if(g){g.call(e,k)}return}var i=new DataView(l),h=i.getUint16(3,true),j=i.getUint16(5,true);e.rd.read(j,f,function(p,q){var m=new DataView(q);var o=new b;o.partial=((h&1)!==0||(h&2)!==0);o.continuesFrom=((h&1)!==0);o.continues=((h&2)!==0);o.offset=f;o.sizePacked=m.getUint32(7,true);o.size=m.getUint32(11,true);o.crc=m.getUint32(16,true);o.time=(function(){var r=m.getUint32(20,true).toString(2);if(r.length<32){r=(new Array(32-r.length+1)).join("0")+r}r=r.match(/(\d{7})(\d{4})(\d{5})(\d{5})(\d{6})(\d{5})/).slice(1).map(function(s){return parseInt(s,2)});return new Date(1980+r[0],r[1]-1,r[2],r[3],r[4],r[5])})();o.os=(function(){var r=m.getUint8(15);switch(r){case 0:return"MS-DOS";case 1:return"OS/2";case 2:return"Windows";case 3:return"Unix";case 4:return"Mac";case 5:return"BeOS"}})();o.version=m.getUint8(24);o.method=m.getUint8(25);o.encrypted=((h&4)!==0);var n=m.getUint16(26,true);if((h&256)!==0){o.sizePacked+=m.getUint32(32,true)*4294967296;o.size+=m.getUint32(36,true)*4294967296;o.path=m.getString(n,40)}else{o.path=m.getString(n,32)}if((h&512)!==0&&o.path.indexOf("\x00")!==-1){o.path=o.path.split("\x00")[0]}o.name=o.path;if(o.name.indexOf("\\")!==-1){o.name=o.name.substr(o.name.lastIndexOf("\\")+1)}else{o.name=o.name.substr(o.name.lastIndexOf("/")+1)}o.headerSize=j;o.blockSize=o.headerSize+o.sizePacked;if(g){g.call(e,null,o)}})})};c.prototype.readHeaders=function(g,h){var f=this;var e=function(m,o){if(m){if(h){h.call(f,m)}return}if(f.abort){if(h){h.call(f,"Read headers prossesing aborted")}return}var j=new DataView(o),n=j.getUint16(0,true),l=j.getUint8(2),i=j.getUint16(3,true),k=j.getUint16(5,true);if((i&32768)!==0){k+=j.getUint32(7,true)}switch(l){case 116:f.parseEntry(g,function(q,p){if(q){if(h){h.call(f,"Read error occurred while reading entry")}return}f.entries.push(p);g+=p.blockSize;if(g>=f.rd.size){if(h){h.call(f,null)}return}f.rd.read(11,g,e)});break;default:g+=k;if(g>=f.rd.size){if(h){h.call(f,null)}return}f.rd.read(11,g,e);break}};if(this.rd.size<=14){if(h){h.call(f,null,this.entries)}return}this.rd.read(11,g,e)};c.prototype.get=function(e,f){if(!this.valid){if(f){f.call(this,"Invalid RAR archive")}return}if(!(e instanceof b)){if(f){f.call(this,"Invalid RAR entry, must be an instance of RarEntry")}return}if(e.method!==b.METHOD_STORE){if(f){f.call(this,"Compression is not yet supported")}return}this.rd.readBlob(e.blockSize-1,e.offset+e.headerSize,function(g,h){if(g){if(f){f.call(self,g)}return}if(f){f.call(self,null,h)}})};c.OPEN_FILE=d.OPEN_FILE;c.OPEN_URI=d.OPEN_URI;c.OPEN_LOCAL=d.OPEN_LOCAL;if(typeof module!=="undefined"&&module.exports){module.exports=c}else{if(typeof define==="function"&&define.amd){define("rar",[],function(){return c})}else{window.RarArchive=c}}})();