mirror of
https://github.com/marcrobledo/RomPatcher.js.git
synced 2025-06-27 16:25:54 +00:00
29 lines
13 KiB
JavaScript
29 lines
13 KiB
JavaScript
|
/*
|
||
|
Copyright (c) 2013 Gildas Lormeau. All rights reserved.
|
||
|
|
||
|
Redistribution and use in source and binary forms, with or without
|
||
|
modification, are permitted provided that the following conditions are met:
|
||
|
|
||
|
1. Redistributions of source code must retain the above copyright notice,
|
||
|
this list of conditions and the following disclaimer.
|
||
|
|
||
|
2. Redistributions in binary form must reproduce the above copyright
|
||
|
notice, this list of conditions and the following disclaimer in
|
||
|
the documentation and/or other materials provided with the distribution.
|
||
|
|
||
|
3. The names of the authors may not be used to endorse or promote products
|
||
|
derived from this software without specific prior written permission.
|
||
|
|
||
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||
|
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
||
|
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||
|
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||
|
*/
|
||
|
!function(b){"use strict";var o,k="File format is not recognized.",a="File contains encrypted entry.",s="File is using Zip64 (4gb+ file size).",w="Error while reading zip file.",n="Error while reading file data.",y=524288,c="text/plain";try{o=0===new Blob([new DataView(new ArrayBuffer(0))]).size}catch(e){}function r(){this.crc=-1}function l(){}function A(e,t){var r,n;return r=new ArrayBuffer(e),n=new Uint8Array(r),t&&n.set(t,0),{buffer:r,array:n,view:new DataView(r)}}function e(){}function t(n){var i,o=this;o.size=0,o.init=function(e,t){var r=new Blob([n],{type:c});(i=new f(r)).init(function(){o.size=i.size,e()},t)},o.readUint8Array=function(e,t,r,n){i.readUint8Array(e,t,r,n)}}function i(f){var u,r=this;r.size=0,r.init=function(e){for(var t=f.length;"="==f.charAt(t-1);)t--;u=f.indexOf(",")+1,r.size=Math.floor(.75*(t-u)),e()},r.readUint8Array=function(e,t,r){var n,i=A(t),o=4*Math.floor(e/3),a=4*Math.ceil((e+t)/3),s=b.atob(f.substring(o+u,a+u)),c=e-3*Math.floor(o/4);for(n=c;n<c+t;n++)i.array[n-c]=s.charCodeAt(n);r(i.array)}}function f(o){var t=this;t.size=0,t.init=function(e){t.size=o.size,e()},t.readUint8Array=function(e,t,r,n){var i=new FileReader;i.onload=function(e){r(new Uint8Array(e.target.result))},i.onerror=n;try{i.readAsArrayBuffer(function(e,t,r){if(t<0||r<0||t+r>e.size)throw new RangeError("offset:"+t+", length:"+r+", size:"+e.size);return e.slice?e.slice(t,t+r):e.webkitSlice?e.webkitSlice(t,t+r):e.mozSlice?e.mozSlice(t,t+r):e.msSlice?e.msSlice(t,t+r):void 0}(o,e,t))}catch(e){n(e)}}}function u(){}function h(n){var i;this.init=function(e){i=new Blob([],{type:c}),e()},this.writeUint8Array=function(e,t){i=new Blob([i,o?e:e.buffer],{type:c}),t()},this.getData=function(t,e){var r=new FileReader;r.onload=function(e){t(e.target.result)},r.onerror=e,r.readAsText(i,n)}}function p(t){var o="",a="";this.init=function(e){o+="data:"+(t||"")+";base64,",e()},this.writeUint8Array=function(e,t){var r,n=a.length,i=a;for(a="",r=0;r<3*Math.floor((n+e.length)/3)-n;r++)i+=String.fromCharCode(e[r]);for(;r<e.length;r++)a+=String.fromCharCode(e[r]);2<i.length?o+=b.btoa(i):a=i,t()},this.getData=function(e){e(o+b.btoa(a))}}function v(r){var n;this.init=function(e){n=new Blob([],{type:r}),e()},this.writeUint8Array=function(e,t){n=new Blob([n,o?e:e.buffer],{type:r}),t()},this.getData=function(e){e(n)}}function S(i,r,e,o,t,a,s,n,c,f){var u,l,w,h=0,p=r.sn;function v(){i.removeEventListener("message",d,!1),n(l,w)}function d(e){var t=e.data,r=t.data,n=t.error;if(n)return n.toString=function(){return"Error: "+this.message},void c(n);if(t.sn===p)switch("number"==typeof t.codecTime&&(i.codecTime+=t.codecTime),"number"==typeof t.crcTime&&(i.crcTime+=t.crcTime),t.type){case"append":r?(l+=r.length,o.writeUint8Array(r,function(){g()},f)):g();break;case"flush":w=t.crc,r?(l+=r.length,o.writeUint8Array(r,function(){v()},f)):v();break;case"progress":s&&s(u+t.loaded,a);break;case"importScripts":case"newTask":case"echo":break;default:console.warn("zip.js:launchWorkerProcess: unknown message: ",t)}}function g(){(u=h*y)<=a?e.readUint8Array(t+u,Math.min(y,a-u),function(e){s&&s(u,a);var t=0===u?r:{sn:p};t.type="append",t.data=e;try{i.postMessage(t,[e.buffer])}catch(e){i.postMessage(t)}h++},c):i.postMessage({sn:p,type:"flush"})}l=0,i.addEventListener("message",d,!1),g()}function _(n,t,i,o,a,e,s,c,f,u){var l,w=0,h=0,p="input"===e,v="output"===e,d=new r;!function r(){var e;if((l=w*y)<a)t.readUint8Array(o+l,Math.min(y,a-l),function(e){var t;try{t=n.append(e,function(e){s&&s(l+e,a)})}catch(e){return void f(e)}t?(h+=t.length,i.writeUint8Array(t,function(){w++,setTimeout(r,1)},u),v&&d.append(t)):(w++,setTimeout(r,1)),p&&d.append(e),s&&s(l,a)},f);else{try{e=n.flush()}catch(e){return void f(e)}e?(v&&d.append(e),h+=e.length,i.writeUint8Array(e,function(){c(h,d.get())},u)):c(h,d.get())}}()}function D(e,t,r,n,i,o,a,s,c,f,u){b.zip.useWebWorkers&&a?S(e,{sn:t,codecClass:"NOOP",crcType:"input"},r,n,i,o,c,s,f,u):_(new l,r,n,i,o,"input",c,s,f,u)}function d(e){var t,r,n="",i=["Ç","ü","é","â","ä","à","å","ç","ê","ë","è","ï","î","ì","Ä","Å","É","æ","Æ","ô","ö"
|