filer/dist/idbfs.min.js

4 lines
553 KiB
JavaScript
Raw Normal View History

/*! idbfs 2013-11-27 */
2013-11-27 03:43:41 +00:00
(function(l,n){"object"==typeof exports?module.exports=n():"function"==typeof define&&define.amd?define(n):l.IDBFS||(l.IDBFS=n())})(this,function(){var l,n,u;(function(e){function t(l,n){return w.call(l,n)}function r(l,n){var u,e,t,r,i,o,a,s,c,f,p=n&&n.split("/"),d=y.map,h=d&&d["*"]||{};if(l&&"."===l.charAt(0))if(n){for(p=p.slice(0,p.length-1),l=p.concat(l.split("/")),s=0;l.length>s;s+=1)if(f=l[s],"."===f)l.splice(s,1),s-=1;else if(".."===f){if(1===s&&(".."===l[2]||".."===l[0]))break;s>0&&(l.splice(s-1,2),s-=2)}l=l.join("/")}else 0===l.indexOf("./")&&(l=l.substring(2));if((p||h)&&d){for(u=l.split("/"),s=u.length;s>0;s-=1){if(e=u.slice(0,s).join("/"),p)for(c=p.length;c>0;c-=1)if(t=d[p.slice(0,c).join("/")],t&&(t=t[e])){r=t,i=s;break}if(r)break;!o&&h&&h[e]&&(o=h[e],a=s)}!r&&o&&(r=o,i=a),r&&(u.splice(0,i,r),l=u.join("/"))}return l}function i(l,n){return function(){return d.apply(e,_.call(arguments,0).concat([l,n]))}}function o(l){return function(n){return r(n,l)}}function a(l){return function(n){v[l]=n}}function s(l){if(t(m,l)){var n=m[l];delete m[l],b[l]=!0,p.apply(e,n)}if(!t(v,l)&&!t(b,l))throw Error("No "+l);return v[l]}function c(l){var n,u=l?l.indexOf("!"):-1;return u>-1&&(n=l.substring(0,u),l=l.substring(u+1,l.length)),[n,l]}function f(l){return function(){return y&&y.config&&y.config[l]||{}}}var p,d,h,g,v={},m={},y={},b={},w=Object.prototype.hasOwnProperty,_=[].slice;h=function(l,n){var u,e=c(l),t=e[0];return l=e[1],t&&(t=r(t,n),u=s(t)),t?l=u&&u.normalize?u.normalize(l,o(n)):r(l,n):(l=r(l,n),e=c(l),t=e[0],l=e[1],t&&(u=s(t))),{f:t?t+"!"+l:l,n:l,pr:t,p:u}},g={require:function(l){return i(l)},exports:function(l){var n=v[l];return n!==void 0?n:v[l]={}},module:function(l){return{id:l,uri:"",exports:v[l],config:f(l)}}},p=function(l,n,u,r){var o,c,f,p,d,y,w=[];if(r=r||l,"function"==typeof u){for(n=!n.length&&u.length?["require","exports","module"]:n,d=0;n.length>d;d+=1)if(p=h(n[d],r),c=p.f,"require"===c)w[d]=g.require(l);else if("exports"===c)w[d]=g.exports(l),y=!0;else if("module"===c)o=w[d]=g.module(l);else if(t(v,c)||t(m,c)||t(b,c))w[d]=s(c);else{if(!p.p)throw Error(l+" missing "+c);p.p.load(p.n,i(r,!0),a(c),{}),w[d]=v[c]}f=u.apply(v[l],w),l&&(o&&o.exports!==e&&o.exports!==v[l]?v[l]=o.exports:f===e&&y||(v[l]=f))}else l&&(v[l]=u)},l=n=d=function(l,n,u,t,r){return"string"==typeof l?g[l]?g[l](n):s(h(l,n).f):(l.splice||(y=l,n.splice?(l=n,n=u,u=null):l=e),n=n||function(){},"function"==typeof u&&(u=t,t=r),t?p(e,l,n,u):setTimeout(function(){p(e,l,n,u)},4),d)},d.config=function(l){return y=l,y.deps&&d(y.deps,y.callback),d},u=function(l,n,u){n.splice||(u=n,n=[]),t(v,l)||t(m,l)||(m[l]=[l,n,u])},u.amd={jQuery:!0}})(),u("build/almond",function(){}),function(l,n){function e(l){return l&&l.__wrapped__?l:this instanceof e?(this.__wrapped__=l,n):new e(l)}function t(l,n,u){n||(n=0);var e=l.length,t=e-n>=(u||Dn),r=t?{}:l;if(t)for(var i,o=n-1;e>++o;)i=l[o]+"",(Xn.call(r,i)?r[i]:r[i]=[]).push(l[o]);return function(l){if(t){var u=l+"";return Xn.call(r,u)&&T(r[u],l)>-1}return T(r,l,n)>-1}}function r(l,u){var e=l.index,t=u.index;if(l=l.criteria,u=u.criteria,l!==u){if(l>u||l===n)return 1;if(u>l||u===n)return-1}return t>e?-1:1}function i(l,n,u){function e(){var o=arguments,a=r?this:n;if(t||(l=n[i]),u.length&&(o=o.length?u.concat(Qn.call(o)):u),this instanceof e){f.prototype=l.prototype,a=new f;var s=l.apply(a,o);return s&&Cu[typeof s]?s:a}return l.apply(a,o)}var t=h(l),r=!u,i=l;return r&&(u=n),e}function o(l,u){return l?"function"!=typeof l?function(n){return n[l]}:u!==n?function(n,e,t){return l.call(u,n,e,t)}:l:dn}function a(){for(var l=-1,n=arguments.length,u={bottom:"",hasDontEnumBug:Sn,isKeysFast:Iu,noArgsEnum:wu,noCharByIndex:Eu,shadowed:$n,top:"",useHas:!0,useStrict:Au,arrayBranch:{},objectBranch:{}};n>++l;){var e=arguments[l];for(var t in e){var i=e[t];/beforeLoop|inLoop/.test(t)?("string"==typeof i&&(i={array:i,object:i}),u.arrayBranch[t]=i.array,u.objectBranch[t]=i.object):u[t]=i}}var a=u.args,s=/^[^,]+/.exec(a)[0],c=u.init;u.firstArg=s,u.init=null==c?s:c,"collection"==s&&u.arrayBranch.inLoop||(u.arrayBranch=null);var f=Function("array
}function u(l,n){return Math.floor(l/n)}function e(l){var n=0;this.get=function(){return n>=l.length?M:Number(l[n])},this.offset=function(u){if(n+=u,0>n)throw Error("Seeking past start of the buffer");if(n>l.length)throw Error("Seeking past EOF")},this.match=function(u){if(u.length>n+l.length)return!1;var e;for(e=0;u.length>e;e+=1)if(Number(l[n+e])!==u[e])return!1;return!0}}function t(l){var n=0;this.emit=function(){var u,e=M;for(u=0;arguments.length>u;++u)e=Number(arguments[u]),l[n++]=e;return e}}function r(l){function u(l){for(var u=[],e=0,t=l.length;l.length>e;){var r=l.charCodeAt(e);if(n(r,55296,57343))if(n(r,56320,57343))u.push(65533);else if(e===t-1)u.push(65533);else{var i=l.charCodeAt(e+1);if(n(i,56320,57343)){var o=1023&r,a=1023&i;e+=1,u.push(65536+(o<<10)+a)}else u.push(65533)}else u.push(r);e+=1}return u}var e=0,t=u(l);this.offset=function(l){if(e+=l,0>e)throw Error("Seeking past start of the buffer");if(e>t.length)throw Error("Seeking past EOF")},this.get=function(){return e>=t.length?P:t[e]}}function i(){var l="";this.string=function(){return l},this.emit=function(n){65535>=n?l+=String.fromCharCode(n):(n-=65536,l+=String.fromCharCode(55296+(1023&n>>10)),l+=String.fromCharCode(56320+(1023&n)))}}function o(l){this.name="EncodingError",this.message=l,this.code=0}function a(l,n){if(l)throw new o("Decoder error");return n||65533}function s(l){throw new o("The code point "+l+" could not be encoded.")}function c(l){return l=(l+"").trim().toLowerCase(),Object.prototype.hasOwnProperty.call(W,l)?W[l]:null}function f(l,n){return(n||[])[l]||null}function p(l,n){var u=n.indexOf(l);return-1===u?null:u}function d(n){if(!("encoding-indexes"in l))throw Error("Indexes missing. Did you forget to include encoding-indexes.js?");return l["encoding-indexes"][n]}function h(l){if(l>39419&&189e3>l||l>1237575)return null;var n,u=0,e=0,t=d("gb18030");for(n=0;t.length>n;++n){var r=t[n];if(!(l>=r[0]))break;u=r[0],e=r[1]}return e+l-u}function g(l){var n,u=0,e=0,t=d("gb18030");for(n=0;t.length>n;++n){var r=t[n];if(!(l>=r[1]))break;u=r[1],e=r[0]}return e+l-u}function v(l){var u=l.fatal,e=0,t=0,r=0,i=0;this.decode=function(l){var o=l.get();if(o===M)return 0!==t?a(u):P;if(l.offset(1),0===t){if(n(o,0,127))return o;if(n(o,194,223))t=1,i=128,e=o-192;else if(n(o,224,239))t=2,i=2048,e=o-224;else{if(!n(o,240,244))return a(u);t=3,i=65536,e=o-240}return e*=Math.pow(64,t),null}if(!n(o,128,191))return e=0,t=0,r=0,i=0,l.offset(-1),a(u);if(r+=1,e+=(o-128)*Math.pow(64,t-r),r!==t)return null;var s=e,c=i;return e=0,t=0,r=0,i=0,n(s,c,1114111)&&!n(s,55296,57343)?s:a(u)}}function m(l){l.fatal,this.encode=function(l,e){var t=e.get();if(t===P)return M;if(e.offset(1),n(t,55296,57343))return s(t);if(n(t,0,127))return l.emit(t);var r,i;n(t,128,2047)?(r=1,i=192):n(t,2048,65535)?(r=2,i=224):n(t,65536,1114111)&&(r=3,i=240);for(var o=l.emit(u(t,Math.pow(64,r))+i);r>0;){var a=u(t,Math.pow(64,r-1));o=l.emit(128+a%64),r-=1}return o}}function y(l,u){var e=u.fatal;this.decode=function(u){var t=u.get();if(t===M)return P;if(u.offset(1),n(t,0,127))return t;var r=l[t-128];return null===r?a(e):r}}function b(l,u){u.fatal,this.encode=function(u,e){var t=e.get();if(t===P)return M;if(e.offset(1),n(t,0,127))return u.emit(t);var r=p(t,l);return null===r&&s(t),u.emit(r+128)}}function w(l,u){var e=u.fatal,t=0,r=0,i=0;this.decode=function(u){var o=u.get();if(o===M&&0===t&&0===r&&0===i)return P;o!==M||0===t&&0===r&&0===i||(t=0,r=0,i=0,a(e)),u.offset(1);var s;if(0!==i)return s=null,n(o,48,57)&&(s=h(10*(126*(10*(t-129)+(r-48))+(i-129))+o-48)),t=0,r=0,i=0,null===s?(u.offset(-3),a(e)):s;if(0!==r)return n(o,129,254)?(i=o,null):(u.offset(-2),t=0,r=0,a(e));if(0!==t){if(n(o,48,57)&&l)return r=o,null;var c=t,p=null;t=0;var g=127>o?64:65;return(n(o,64,126)||n(o,128,254))&&(p=190*(c-129)+(o-g)),s=null===p?null:f(p,d("gbk")),null===p&&u.offset(-1),null===s?a(e):s}return n(o,0,127)?o:128===o?8364:n(o,129,254)?(t=o,null):a(e)}}function _(l,e){e.fatal,this.encode=function(e,t){var r=t.get();if(r===P)return M;if(t.offset(1),n(r,0,127))return e.emit(r);var i=p(r,d("gbk"));if(null!==i){var o=u(i,190)+129,
}n=H(n);var f,p,d,h,g=Y(n),v=U(n);r(l,v,e)}function s(l,u,t,i){function o(n,u){n?i(n):(v=u,l.get(v.data,a))}function a(n,u){n?i(n):(m=u,W(m).has(_)?W(t).contains(_n)?i(new J("O_CREATE and O_EXCLUSIVE are set, and the named file exists")):(y=m[_],y.type==cn&&W(t).contains(bn)?i(new G("the named file is a directory and O_WRITE is set")):l.get(y.id,s)):W(t).contains(wn)?p():i(new J("O_CREATE is not set and the named file does not exist")))}function s(l,n){if(l)i(l);else{var u=n;u.mode==fn?(E++,E>hn?i(new tn("too many symbolic links were encountered")):c(u.data)):f(void 0,u)}}function c(n){n=H(n),x=U(n),_=Y(n),pn==_&&(W(t).contains(bn)?i(new G("the named file is a directory and O_WRITE is set")):r(l,u,f)),r(l,x,o)}function f(l,n){l?i(l):(b=n,i(null,b))}function p(){b=new e(void 0,sn),b.nlinks+=1,l.put(b.id,b,d)}function d(n){n?i(n):(w=new Uint8Array(0),l.put(b.data,w,h))}function h(u){u?i(u):(m[_]=new n(b.id,sn),l.put(v.data,m,g))}function g(l){l?i(l):i(null,b)}u=H(u);var v,m,y,b,w,_=Y(u),x=U(u),E=0;pn==_?W(t).contains(bn)?i(new G("the named file is a directory and O_WRITE is set")):r(l,u,f):r(l,x,o)}function c(l,n,u,e,t,r,i){function o(l){l?i(l):i(null,t)}function a(n){n?i(n):l.put(f.id,f,o)}function s(e,o){if(e)i(e);else{p=o;var s=void 0!==r&&null!==r?r:n.position,c=Math.max(p.length,s+t),d=new Uint8Array(c);p&&d.set(p),d.set(u,s),void 0===r&&(n.position+=t),f.size=c,f.mtime=Date.now(),f.version+=1,l.put(f.data,d,a)}}function c(n,u){n?i(n):(f=u,l.get(f.data,s))}var f,p;l.get(n.id,c)}function f(l,n,u,e,t,r,i){function o(l,o){if(l)i(l);else{c=o;var a=void 0!==r&&null!==r?r:n.position;t=a+t>u.length?t-a:t;var s=c.subarray(a,a+t);u.set(s,e),void 0===r&&(n.position+=t),i(null,t)}}function a(n,u){n?i(n):(s=u,l.get(s.data,o))}var s,c;l.get(n.id,a)}function p(l,n,u){function e(l,n){l?u(l):u(null,n)}n=H(n),Y(n),r(l,n,e)}function d(l,n,u){function e(l,n){l?u(l):u(null,n)}l.get(n.id,e)}function h(l,n,u){function e(n,e){n?u(n):(o=e,l.get(o.data,t))}function t(n,e){n?u(n):(a=e,W(a).has(s)?l.get(a[s].id,i):u(new J("a component of the path does not name an existing file")))}function i(l,n){l?u(l):u(null,n)}n=H(n);var o,a,s=Y(n),c=U(n);pn==s?l.get(dn,i):r(l,c,e)}function g(l,n,u,e){function t(n,u){n?e(n):(m=u,m.nlinks+=1,l.put(m.id,m,e))}function i(n){n?e(n):l.get(v[y].id,t)}function o(n,u){n?e(n):(v=u,W(v).has(y)?e(new X("newpath resolves to an existing file")):(v[y]=h[f],l.put(g.data,v,i)))}function a(n,u){n?e(n):(g=u,l.get(g.data,o))}function s(n,u){n?e(n):(h=u,W(h).has(f)?r(l,b,a):e(new J("a component of either path prefix does not exist")))}function c(n,u){n?e(n):(d=u,l.get(d.data,s))}n=H(n);var f=Y(n),p=U(n);u=H(u);var d,h,g,v,m,y=Y(u),b=U(u);r(l,p,c)}function v(l,n,u){function e(n){n?u(n):(delete c[p],l.put(s.data,c,u))}function t(n){n?u(n):l.delete(f.data,e)}function i(n,r){n?u(n):(f=r,f.nlinks-=1,1>f.nlinks?l.delete(f.id,t):l.put(f.id,f,e))}function o(n,e){n?u(n):(c=e,W(c).has(p)?l.get(c[p].id,i):u(new J("a component of the path does not name an existing file")))}function a(n,e){n?u(n):(s=e,l.get(s.data,o))}n=H(n);var s,c,f,p=Y(n),d=U(n);r(l,d,a)}function m(l,n,u){function e(l,n){if(l)u(l);else{o=n;var e=Object.keys(o);u(null,e)}}function t(n,t){n?u(n):(i=t,l.get(i.data,e))}n=H(n),Y(n);var i,o;r(l,n,t)}function y(l,u,t,i){function o(n,u){n?i(n):(f=u,l.get(f.data,a))}function a(l,n){l?i(l):(p=n,W(p).has(h)?i(new X("the destination path already exists")):s())}function s(){d=new e(void 0,fn),d.nlinks+=1,d.size=u.length,d.data=u,l.put(d.id,d,c)}function c(u){u?i(u):(p[h]=new n(d.id,fn),l.put(f.data,p,i))}t=H(t);var f,p,d,h=Y(t),g=U(t);pn==h?i(new X("the destination path already exists")):r(l,g,o)}function b(l,n,u){function e(n,e){n?u(n):(o=e,l.get(o.data,t))}function t(n,e){n?u(n):(a=e,W(a).has(s)?l.get(a[s].id,i):u(new J("a component of the path does not name an existing file")))}function i(l,n){l?u(l):n.mode!=fn?u(new un("path not a symbolic link")):u(null,n.data)}n=H(n);var o,a,s=Y(n),c=U(n);r(l,c,e)}function w(l){return W(En).has(l)?En[l]:null}function _(l,n){if(-1!==(""+l).indexOf("\0")){var u=Error("Path must be a string witho