filer/dist/filer.min.js

5 lines
102 KiB
JavaScript
Raw Normal View History

2014-02-21 17:39:33 +00:00
/*! filer 2014-02-21 */
(function(t,n){"object"==typeof exports?module.exports=n():"function"==typeof define&&define.amd?define(n):t.Filer||(t.Filer=n())})(this,function(){var t,n,e;(function(r){function i(t,n){return w.call(t,n)}function o(t,n){var e,r,i,o,s,a,c,u,f,l,h=n&&n.split("/"),p=m.map,d=p&&p["*"]||{};if(t&&"."===t.charAt(0))if(n){for(h=h.slice(0,h.length-1),t=h.concat(t.split("/")),u=0;t.length>u;u+=1)if(l=t[u],"."===l)t.splice(u,1),u-=1;else if(".."===l){if(1===u&&(".."===t[2]||".."===t[0]))break;u>0&&(t.splice(u-1,2),u-=2)}t=t.join("/")}else 0===t.indexOf("./")&&(t=t.substring(2));if((h||d)&&p){for(e=t.split("/"),u=e.length;u>0;u-=1){if(r=e.slice(0,u).join("/"),h)for(f=h.length;f>0;f-=1)if(i=p[h.slice(0,f).join("/")],i&&(i=i[r])){o=i,s=u;break}if(o)break;!a&&d&&d[r]&&(a=d[r],c=u)}!o&&a&&(o=a,s=c),o&&(e.splice(0,s,o),t=e.join("/"))}return t}function s(t,n){return function(){return p.apply(r,E.call(arguments,0).concat([t,n]))}}function a(t){return function(n){return o(n,t)}}function c(t){return function(n){v[t]=n}}function u(t){if(i(y,t)){var n=y[t];delete y[t],b[t]=!0,h.apply(r,n)}if(!i(v,t)&&!i(b,t))throw Error("No "+t);return v[t]}function f(t){var n,e=t?t.indexOf("!"):-1;return e>-1&&(n=t.substring(0,e),t=t.substring(e+1,t.length)),[n,t]}function l(t){return function(){return m&&m.config&&m.config[t]||{}}}var h,p,d,g,v={},y={},m={},b={},w=Object.prototype.hasOwnProperty,E=[].slice;d=function(t,n){var e,r=f(t),i=r[0];return t=r[1],i&&(i=o(i,n),e=u(i)),i?t=e&&e.normalize?e.normalize(t,a(n)):o(t,n):(t=o(t,n),r=f(t),i=r[0],t=r[1],i&&(e=u(i))),{f:i?i+"!"+t:t,n:t,pr:i,p:e}},g={require:function(t){return s(t)},exports:function(t){var n=v[t];return n!==void 0?n:v[t]={}},module:function(t){return{id:t,uri:"",exports:v[t],config:l(t)}}},h=function(t,n,e,o){var a,f,l,h,p,m,w=[];if(o=o||t,"function"==typeof e){for(n=!n.length&&e.length?["require","exports","module"]:n,p=0;n.length>p;p+=1)if(h=d(n[p],o),f=h.f,"require"===f)w[p]=g.require(t);else if("exports"===f)w[p]=g.exports(t),m=!0;else if("module"===f)a=w[p]=g.module(t);else if(i(v,f)||i(y,f)||i(b,f))w[p]=u(f);else{if(!h.p)throw Error(t+" missing "+f);h.p.load(h.n,s(o,!0),c(f),{}),w[p]=v[f]}l=e.apply(v[t],w),t&&(a&&a.exports!==r&&a.exports!==v[t]?v[t]=a.exports:l===r&&m||(v[t]=l))}else t&&(v[t]=e)},t=n=p=function(t,n,e,i,o){return"string"==typeof t?g[t]?g[t](n):u(d(t,n).f):(t.splice||(m=t,n.splice?(t=n,n=e,e=null):t=r),n=n||function(){},"function"==typeof e&&(e=i,i=o),i?h(r,t,n,e):setTimeout(function(){h(r,t,n,e)},4),p)},p.config=function(t){return m=t,m.deps&&p(m.deps,m.callback),p},e=function(t,n,e){n.splice||(e=n,n=[]),i(v,t)||i(y,t)||(y[t]=[t,n,e])},e.amd={jQuery:!0}})(),e("build/almond",function(){}),e("nodash",["require"],function(){function t(t,n){return p.call(t,n)}function n(t){return null==t?0:t.length===+t.length?t.length:v(t).length}function e(t){return t}function r(t,n,e){var r,i;if(null!=t)if(u&&t.forEach===u)t.forEach(n,e);else if(t.length===+t.length){for(r=0,i=t.length;i>r;r++)if(n.call(e,t[r],r,t)===g)return}else{var o=o(t);for(r=0,i=o.length;i>r;r++)if(n.call(e,t[o[r]],o[r],t)===g)return}}function i(t,n,i){n||(n=e);var o=!1;return null==t?o:l&&t.some===l?t.some(n,i):(r(t,function(t,e,r){return o||(o=n.call(i,t,e,r))?g:void 0}),!!o)}function o(t,n){return null==t?!1:f&&t.indexOf===f?-1!=t.indexOf(n):i(t,function(t){return t===n})}function s(t){this.value=t}function a(t){return t&&"object"==typeof t&&!Array.isArray(t)&&p.call(t,"__wrapped__")?t:new s(t)}var c=Array.prototype,u=c.forEach,f=c.indexOf,l=c.some,h=Object.prototype,p=h.hasOwnProperty,d=Object.keys,g={},v=d||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var e=[];for(var r in n)t(n,r)&&e.push(r);return e};return s.prototype.has=function(n){return t(this.value,n)},s.prototype.contains=function(t){return o(this.value,t)},s.prototype.size=function(){return n(this.value)},a}),function(t){t["encoding-indexes"]=t["encoding-indexes"]||[]}(this),e("encoding-indexes-shim",function(){}),function(t){function n(t,n,e){return t>=n&&e>=t}function e(t,n){return Math.floor(t/n)}function r(t){var n=0;this.get
}var r=t("src/constants").FILE_SYSTEM_NAME,i=t("src/constants").FILE_STORE_NAME,o=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,s=t("src/constants").IDB_RW,a=t("src/constants").IDB_RO;return n.prototype.clear=function(t){try{var n=this.objectStore.clear();n.onsuccess=function(){t()},n.onerror=function(n){t(n)}}catch(e){t(e)}},n.prototype.get=function(t,n){try{var e=this.objectStore.get(t);e.onsuccess=function(t){var e=t.target.result;n(null,e)},e.onerror=function(t){n(t)}}catch(r){n(r)}},n.prototype.put=function(t,n,e){try{var r=this.objectStore.put(n,t);r.onsuccess=function(t){var n=t.target.result;e(null,n)},r.onerror=function(t){e(t)}}catch(i){e(i)}},n.prototype.delete=function(t,n){try{var e=this.objectStore.delete(t);e.onsuccess=function(t){var e=t.target.result;n(null,e)},e.onerror=function(t){n(t)}}catch(r){n(r)}},e.isSupported=function(){return!!o},e.prototype.open=function(t){var n=this;if(n.db)return t(null,!1),void 0;var e=!1,r=o.open(n.name);r.onupgradeneeded=function(t){var n=t.target.result;n.objectStoreNames.contains(i)&&n.deleteObjectStore(i),n.createObjectStore(i),e=!0},r.onsuccess=function(r){n.db=r.target.result,t(null,e)},r.onerror=function(n){t(n)}},e.prototype.getReadOnlyContext=function(){return new n(this.db,a)},e.prototype.getReadWriteContext=function(){return new n(this.db,s)},e}),e("src/providers/websql",["require","src/constants","src/constants","src/constants","src/constants","src/constants"],function(t){function n(t,n){var e=this;this.getTransaction=function(r){return e.transaction?(r(e.transaction),void 0):(t[n?"readTransaction":"transaction"](function(t){e.transaction=t,r(t)}),void 0)}}function e(t){this.name=t||r,this.db=null}var r=t("src/constants").FILE_SYSTEM_NAME,i=t("src/constants").FILE_STORE_NAME,o=t("src/constants").WSQL_VERSION,s=t("src/constants").WSQL_SIZE,a=t("src/constants").WSQL_DESC;return n.prototype.clear=function(t){function n(n,e){t(e)}function e(){t(null)}this.getTransaction(function(t){t.executeSql("DELETE FROM "+i,[],e,n)})},n.prototype.get=function(t,n){function e(t,e){var r=0===e.rows.length?null:e.rows.item(0).data;n(null,r)}function r(t,e){n(e)}this.getTransaction(function(n){n.executeSql("SELECT data FROM "+i+" WHERE id = ?",[t],e,r)})},n.prototype.put=function(t,n,e){function r(){e(null)}function o(t,n){e(n)}this.getTransaction(function(e){e.executeSql("INSERT OR REPLACE INTO "+i+" (id, data) VALUES (?, ?)",[t,n],r,o)})},n.prototype.delete=function(t,n){function e(){n(null)}function r(t,e){n(e)}this.getTransaction(function(n){n.executeSql("DELETE FROM "+i+" WHERE id = ?",[t],e,r)})},e.isSupported=function(){return!!window.openDatabase},e.prototype.open=function(t){function n(n,e){t(e)}function e(n){function e(n,e){var r=0===e.rows.item(0).count;t(null,r)}function o(n,e){t(e)}r.db=c,n.executeSql("SELECT COUNT(id) AS count FROM "+i+";",[],e,o)}var r=this;if(r.db)return t(null,!1),void 0;var c=window.openDatabase(r.name,o,a,s);return c?(c.transaction(function(t){t.executeSql("CREATE TABLE IF NOT EXISTS "+i+" (id unique, data)",[],e,n)}),void 0):(t("[WebSQL] Unable to open database."),void 0)},e.prototype.getReadOnlyContext=function(){return new n(this.db,!0)},e.prototype.getReadWriteContext=function(){return new n(this.db,!1)},e}),function(){function t(t){var e=!1;return function(){if(e)throw Error("Callback was already called.");e=!0,t.apply(n,arguments)}}var n,r,i={};n=this,null!=n&&(r=n.async),i.noConflict=function(){return n.async=r,i};var o=function(t,n){if(t.forEach)return t.forEach(n);for(var e=0;t.length>e;e+=1)n(t[e],e,t)},s=function(t,n){if(t.map)return t.map(n);var e=[];return o(t,function(t,r,i){e.push(n(t,r,i))}),e},a=function(t,n,e){return t.reduce?t.reduce(n,e):(o(t,function(t,r,i){e=n(e,t,r,i)}),e)},c=function(t){if(Object.keys)return Object.keys(t);var n=[];for(var e in t)t.hasOwnProperty(e)&&n.push(e);return n};"undefined"!=typeof process&&process.nextTick?(i.nextTick=process.nextTick,i.setImmediate="undefined"!=typeof setImmediate?function(t){setImmediate(t)}:i.nextTick):"function"==typeof setImmediate?(i.nex
}),n("Zlib.Deflate.prototype.compress",m.prototype.j),b("Zlib.Deflate.CompressionType",{NONE:on.NONE,FIXED:on.r,DYNAMIC:on.k})}.call(this),e("zlib",function(){}),e("src/adapters/zlib",["require","zlib"],function(t){function n(t){return new o(t).decompress()}function e(t){return new s(t).compress()}function r(t){this.context=t}function i(t){this.provider=t}t("zlib");var o=Zlib.Inflate,s=Zlib.Deflate;return r.prototype.clear=function(t){this.context.clear(t)},r.prototype.get=function(t,e){this.context.get(t,function(t,r){return t?(e(t),void 0):(r&&(r=n(r)),e(null,r),void 0)})},r.prototype.put=function(t,n,r){n=e(n),this.context.put(t,n,r)},r.prototype.delete=function(t,n){this.context.delete(t,n)},i.isSupported=function(){return!0},i.prototype.open=function(t){this.provider.open(t)},i.prototype.getReadOnlyContext=function(){return new r(this.provider.getReadOnlyContext())},i.prototype.getReadWriteContext=function(){return new r(this.provider.getReadWriteContext())},i});var r=r||function(t,n){var e={},r=e.lib={},i=r.Base=function(){function t(){}return{extend:function(n){t.prototype=this;var e=new t;return n&&e.mixIn(n),e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var n in t)t.hasOwnProperty(n)&&(this[n]=t[n]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.$super.extend(this)}}}(),o=r.WordArray=i.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=e!=n?e:4*t.length},toString:function(t){return(t||a).stringify(this)},concat:function(t){var n=this.words,e=t.words,r=this.sigBytes,t=t.sigBytes;if(this.clamp(),r%4)for(var i=0;t>i;i++)n[r+i>>>2]|=(255&e[i>>>2]>>>24-8*(i%4))<<24-8*((r+i)%4);else if(e.length>65535)for(i=0;t>i;i+=4)n[r+i>>>2]=e[i>>>2];else n.push.apply(n,e);return this.sigBytes+=t,this},clamp:function(){var n=this.words,e=this.sigBytes;n[e>>>2]&=4294967295<<32-8*(e%4),n.length=t.ceil(e/4)},clone:function(){var t=i.clone.call(this);return t.words=this.words.slice(0),t},random:function(n){for(var e=[],r=0;n>r;r+=4)e.push(0|4294967296*t.random());return o.create(e,n)}}),s=e.enc={},a=s.Hex={stringify:function(t){for(var n=t.words,t=t.sigBytes,e=[],r=0;t>r;r++){var i=255&n[r>>>2]>>>24-8*(r%4);e.push((i>>>4).toString(16)),e.push((15&i).toString(16))}return e.join("")},parse:function(t){for(var n=t.length,e=[],r=0;n>r;r+=2)e[r>>>3]|=parseInt(t.substr(r,2),16)<<24-4*(r%8);return o.create(e,n/2)}},c=s.Latin1={stringify:function(t){for(var n=t.words,t=t.sigBytes,e=[],r=0;t>r;r++)e.push(String.fromCharCode(255&n[r>>>2]>>>24-8*(r%4)));return e.join("")},parse:function(t){for(var n=t.length,e=[],r=0;n>r;r++)e[r>>>2]|=(255&t.charCodeAt(r))<<24-8*(r%4);return o.create(e,n)}},u=s.Utf8={stringify:function(t){try{return decodeURIComponent(escape(c.stringify(t)))}catch(n){throw Error("Malformed UTF-8 data")}},parse:function(t){return c.parse(unescape(encodeURIComponent(t)))}},f=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=o.create(),this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=u.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(n){var e=this._data,r=e.words,i=e.sigBytes,s=this.blockSize,a=i/(4*s),a=n?t.ceil(a):t.max((0|a)-this._minBufferSize,0),n=a*s,i=t.min(4*n,i);if(n){for(var c=0;n>c;c+=s)this._doProcessBlock(r,c);c=r.splice(0,n),e.sigBytes-=i}return o.create(c,i)},clone:function(){var t=i.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0});r.Hasher=f.extend({init:function(){this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize(),this._hash},clone:function(){var t=f.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:16,_createHelper:function(t){return function(n,e){return t.create(e).finalize(n)}},_createHmacHelper:function(t){return function(n,e){return l.HMAC.create(t,e).finalize(n)}}});var l=e.algo={};return e}(Math);(function(){var t=r,n=t.lib.WordArray;t.enc.
}j(n,r)&&C(t,n,e,i)}function J(t,n,e,r,i){function o(t,n){t?i(t):i(null,n)}var s=t.openFiles[e];s?I(n,s,r,o):i(new Cn("invalid file descriptor"))}function tn(t,n,e,r,i,o){function s(t){t?o(t):o(null)}j(n,o)&&O(t,n,e,r,i,s)}function nn(t,n,e,r,i,o,s){function a(t){t?s(t):s(null)}var c=t.openFiles[e];c?gn(c.flags).contains(Vn)?R(n,c,r,i,o,a):s(new Cn("descriptor does not permit writing")):s(new Cn("invalid file descriptor"))}function en(t,n,e,r){function i(t){t?r(t):r(null)}j(n,r)&&D(t,n,e,i)}function rn(t,n,e,r,i){function o(t){t?i(t):i(null)}var s=t.openFiles[e];s?gn(s.flags).contains(Vn)?T(n,s,r,o):i(new Cn("descriptor does not permit writing")):i(new Cn("invalid file descriptor"))}function on(t,n,e,r,i,o){function s(t,n){t?o(t):0>n.size+r?o(new In("resulting file offset would be negative")):(a.position=n.size+r,o(null,a.position))}var a=t.openFiles[e];a||o(new Cn("invalid file descriptor")),"SET"===i?0>r?o(new In("resulting file offset would be negative")):(a.position=r,o(null,a.position)):"CUR"===i?0>a.position+r?o(new In("resulting file offset would be negative")):(a.position+=r,o(null,a.position)):"END"===i?v(n,a,s):o(new In("whence argument is not a proper value"))}function sn(t,n,e){function r(t,n){t?e(t):e(null,n)}j(n,e)&&w(t,n,r)}function an(t,n,e,r,i){function o(t){t?i(t):i(null)}if(j(n,i)){var s=Date.now();e=e?e:s,r=r?r:s,A(t,n,e,r,o)}}function cn(t,n,e,r,i,o){function s(t){t?o(t):o(null)}var a=Date.now();r=r?r:a,i=i?i:a;var c=t.openFiles[e];c?gn(c.flags).contains(Vn)?S(n,c,r,i,s):o(new Cn("descriptor does not permit writing")):o(new Cn("invalid file descriptor"))}function un(t,n,e,r){function i(t){t?r(t):r(null)}function o(e){e?r(e):b(t,n,i)}j(n,r)&&j(e,r)&&m(t,n,e,o)}function fn(t,n,e,r){function i(t){t?r(t):r(null)}j(n,r)&&j(e,r)&&E(t,n,e,i)}function ln(t,n,e){function r(t,n){t?e(t):e(null,n)}j(n,e)&&x(t,n,r)}function hn(t,n,e,r){function i(n,e){if(n)r(n);else{var i=new o(e,t.name);r(null,i)}}j(e,r)&&y(n,e,i)}function pn(t,n,e,r){function i(t){t?r(t):r(null)}j(n,r)&&_(t,n,e,i)}function dn(t,n,e,r,i){function o(t){t?i(t):i(null)}var s=t.openFiles[e];s?gn(s.flags).contains(Vn)?k(n,s,r,o):i(new Cn("descriptor does not permit writing")):i(new Cn("invalid file descriptor"))}var gn=t("nodash");t("encoding");var vn=t("src/path").normalize,yn=t("src/path").dirname,mn=t("src/path").basename,bn=t("src/path").isAbsolute,wn=t("src/path").isNull,En=t("src/shared").guid;t("src/shared").hash;var xn=t("src/shared").nop,_n=t("src/error").EExists,kn=t("src/error").EIsDirectory,An=t("src/error").ENoEntry,Sn=t("src/error").EBusy,On=t("src/error").ENotEmpty,Rn=t("src/error").ENotDirectory,Cn=t("src/error").EBadFileDescriptor;t("src/error").ENotImplemented,t("src/error").ENotMounted;var In=t("src/error").EInvalid,Dn=t("src/error").EIO,Tn=t("src/error").ELoop,Bn=t("src/error").EFileSystemError,Mn=t("src/error").ENoAttr,jn=t("src/constants").FILE_SYSTEM_NAME,zn=t("src/constants").FS_FORMAT,Nn=t("src/constants").MODE_FILE,Fn=t("src/constants").MODE_DIRECTORY,Un=t("src/constants").MODE_SYMBOLIC_LINK,Ln=t("src/constants").MODE_META,Pn=t("src/constants").ROOT_DIRECTORY_NAME,Wn=t("src/constants").SUPER_NODE_ID,qn=t("src/constants").SYMLOOP_MAX,Hn=t("src/constants").FS_READY,Yn=t("src/constants").FS_PENDING,Xn=t("src/constants").FS_ERROR,Kn=t("src/constants").O_READ,Vn=t("src/constants").O_WRITE,Zn=t("src/constants").O_CREATE,Qn=t("src/constants").O_EXCLUSIVE;t("src/constants").O_TRUNCATE;var Gn=t("src/constants").O_APPEND,$n=t("src/constants").O_FLAGS,Jn=t("src/constants").XATTR_CREATE,te=t("src/constants").XATTR_REPLACE,ne=t("src/providers/providers"),ee=t("src/adapters/adapters"),re=t("src/shell");return N.providers=ne,N.adapters=ee,N.prototype.open=function(t,n,e,r){r=z(arguments[arguments.length-1]);var i=this,o=i.queueOrRun(function(){var e=i.provider.getReadWriteContext();F(i,e,t,n,r)});o&&r(o)},N.prototype.close=function(t,n){U(this,t,z(n))},N.prototype.mkdir=function(t,n,e){"function"==typeof n&&(e=n),e=z(e);var r=this,i=r.queueOrRun(function(){var n=r.provider.getReadWriteContext();L(n,t,e)});i&&e(i)},N.prototype.rmdir=functi