filer/dist/filer.min.js

5 lines
102 KiB
JavaScript
Raw Normal View History

2014-02-20 22:20:23 +00:00
/*! filer 2014-02-20 */
(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,a,s,u,c,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("/")),c=0;t.length>c;c+=1)if(l=t[c],"."===l)t.splice(c,1),c-=1;else if(".."===l){if(1===c&&(".."===t[2]||".."===t[0]))break;c>0&&(t.splice(c-1,2),c-=2)}t=t.join("/")}else 0===t.indexOf("./")&&(t=t.substring(2));if((h||d)&&p){for(e=t.split("/"),c=e.length;c>0;c-=1){if(r=e.slice(0,c).join("/"),h)for(f=h.length;f>0;f-=1)if(i=p[h.slice(0,f).join("/")],i&&(i=i[r])){o=i,a=c;break}if(o)break;!s&&d&&d[r]&&(s=d[r],u=c)}!o&&s&&(o=s,a=u),o&&(e.splice(0,a,o),t=e.join("/"))}return t}function a(t,n){return function(){return p.apply(r,E.call(arguments,0).concat([t,n]))}}function s(t){return function(n){return o(n,t)}}function u(t){return function(n){v[t]=n}}function c(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=c(i)),i?t=e&&e.normalize?e.normalize(t,s(n)):o(t,n):(t=o(t,n),r=f(t),i=r[0],t=r[1],i&&(e=c(i))),{f:i?i+"!"+t:t,n:t,pr:i,p:e}},g={require:function(t){return a(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 s,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)s=w[p]=g.module(t);else if(i(v,f)||i(y,f)||i(b,f))w[p]=c(f);else{if(!h.p)throw Error(t+" missing "+f);h.p.load(h.n,a(o,!0),u(f),{}),w[p]=v[f]}l=e.apply(v[t],w),t&&(s&&s.exports!==r&&s.exports!==v[t]?v[t]=s.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):c(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("lib/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(c&&t.forEach===c)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 a(t){this.value=t}function s(t){return t&&"object"==typeof t&&!Array.isArray(t)&&p.call(t,"__wrapped__")?t:new a(t)}var u=Array.prototype,c=u.forEach,f=u.indexOf,l=u.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 a.prototype.has=function(n){return t(this.value,n)},a.prototype.contains=function(t){return o(this.value,t)},a.prototype.size=function(){return n(this.value)},s}),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=function(){return n>=t.length?F:Number(t[n])},this.offset=function(e){if(n+=e,0>n)throw Error("Seeking
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,s)},e.prototype.getReadWriteContext=function(){return new n(this.db,a)},e}),e("src/providers/websql",["require","../constants","../constants","../constants","../constants","../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("../constants").FILE_SYSTEM_NAME,i=t("../constants").FILE_STORE_NAME,o=t("../constants").WSQL_VERSION,a=t("../constants").WSQL_SIZE,s=t("../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=u,n.executeSql("SELECT COUNT(id) AS count FROM "+i+";",[],e,o)}var r=this;if(r.db)return t(null,!1),void 0;var u=window.openDatabase(r.name,o,s,a);return u?(u.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)},a=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},s=function(t,n,e){return t.reduce?t.reduce(n,e):(o(t,function(t,r,i){e=n(e,t,r,i)}),e)},u=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.nextTick=function(t){setImmediate(t)},i.setImmediate=i.nextTick):(i.nextTick=function(t){setTimeout(t,0)},i.setImmediate=i.nextTick),i.each=function(n,e,r){if(r=r||function(){},!n.length)return r();var i=0;o(n,function(o){e(o,t(function(t){t?(r(t),r=function(){}):(i+=1,i>=n.length&&r(null))}))})},i.forEa
}function e(t){return new a(t).compress()}function r(t){this.context=t}function i(t){this.provider=t}t("../../lib/zlib");var o=Zlib.Inflate,a=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||s).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)}}),a=e.enc={},s=a.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)}},u=a.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)}},c=a.Utf8={stringify:function(t){try{return decodeURIComponent(escape(u.stringify(t)))}catch(n){throw Error("Malformed UTF-8 data")}},parse:function(t){return u.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=c.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(n){var e=this._data,r=e.words,i=e.sigBytes,a=this.blockSize,s=i/(4*a),s=n?t.ceil(s):t.max((0|s)-this._minBufferSize,0),n=s*a,i=t.min(4*n,i);if(n){for(var u=0;n>u;u+=a)this._doProcessBlock(r,u);u=r.splice(0,n),e.sigBytes-=i}return o.create(u,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.Base64={stringify:function(t){var n=t.words,e=t.sigBytes,r=this._map;t.clamp();for(var t=[],i=0;e>i;i+=3)for(var o=(255&n[i>>>2]>>>24-8*(i%4))<<16|(255&n[i+1>>>2]>>>24-8*((i+1)%4))<<8|255&n[i+2>>>2]>>>24-8*((i+2)%4),a=0;4>a&&e>i+.75*a;a++)t.push(r
}function nn(t,n,e,r){function i(t){t?r(t):r(null)}j(n,r)&&D(t,n,e,i)}function en(t,n,e,r,i){function o(t){t?i(t):i(null)}var a=t.openFiles[e];a?dn(a.flags).contains(Yn)?T(n,a,r,o):i(new Sn("descriptor does not permit writing")):i(new Sn("invalid file descriptor"))}function rn(t,n,e,r,i,o){function a(t,n){t?o(t):0>n.size+r?o(new On("resulting file offset would be negative")):(s.position=n.size+r,o(null,s.position))}var s=t.openFiles[e];s||o(new Sn("invalid file descriptor")),"SET"===i?0>r?o(new On("resulting file offset would be negative")):(s.position=r,o(null,s.position)):"CUR"===i?0>s.position+r?o(new On("resulting file offset would be negative")):(s.position+=r,o(null,s.position)):"END"===i?v(n,s,a):o(new On("whence argument is not a proper value"))}function on(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 a=Date.now();e=e?e:a,r=r?r:a,A(t,n,e,r,o)}}function sn(t,n,e,r,i,o){function a(t){t?o(t):o(null)}var s=Date.now();r=r?r:s,i=i?i:s;var u=t.openFiles[e];u?dn(u.flags).contains(Yn)?S(n,u,r,i,a):o(new Sn("descriptor does not permit writing")):o(new Sn("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 cn(t,n,e,r){function i(t){t?r(t):r(null)}j(n,r)&&j(e,r)&&E(t,n,e,i)}function fn(t,n,e){function r(t,n){t?e(t):e(null,n)}j(n,e)&&x(t,n,r)}function ln(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 hn(t,n,e,r){function i(t){t?r(t):r(null)}j(n,r)&&_(t,n,e,i)}function pn(t,n,e,r,i){function o(t){t?i(t):i(null)}var a=t.openFiles[e];a?dn(a.flags).contains(Yn)?k(n,a,r,o):i(new Sn("descriptor does not permit writing")):i(new Sn("invalid file descriptor"))}var dn=t("./../lib/nodash");t("./../lib/encoding");var gn=t("./path").normalize,vn=t("./path").dirname,yn=t("./path").basename,mn=t("./shared").guid;t("./shared").hash;var bn=t("./shared").nop,wn=t("./error").EExists,En=t("./error").EIsDirectory,xn=t("./error").ENoEntry,_n=t("./error").EBusy,kn=t("./error").ENotEmpty,An=t("./error").ENotDirectory,Sn=t("./error").EBadFileDescriptor;t("./error").ENotImplemented,t("./error").ENotMounted;var On=t("./error").EInvalid,Rn=t("./error").EIO,Cn=t("./error").ELoop,In=t("./error").EFileSystemError,Dn=t("./error").ENoAttr,Tn=t("./constants").FILE_SYSTEM_NAME,Bn=t("./constants").FS_FORMAT,Mn=t("./constants").MODE_FILE,jn=t("./constants").MODE_DIRECTORY,zn=t("./constants").MODE_SYMBOLIC_LINK,Nn=t("./constants").MODE_META,Fn=t("./constants").ROOT_DIRECTORY_NAME,Un=t("./constants").SUPER_NODE_ID,Ln=t("./constants").SYMLOOP_MAX,Pn=t("./constants").FS_READY,Wn=t("./constants").FS_PENDING,qn=t("./constants").FS_ERROR,Hn=t("./constants").O_READ,Yn=t("./constants").O_WRITE,Xn=t("./constants").O_CREATE,Kn=t("./constants").O_EXCLUSIVE;t("./constants").O_TRUNCATE;var Vn=t("./constants").O_APPEND,Zn=t("./constants").O_FLAGS,Qn=t("./constants").XATTR_CREATE,Gn=t("./constants").XATTR_REPLACE,$n=t("src/providers/providers"),Jn=t("src/adapters/adapters"),te=t("src/shell");return N.providers=$n,N.adapters=Jn,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=function(t,n){n=z(n);var e=this,r=e.queueOrRun(function(){var r=e.provider.getReadWriteContext();P(r,t,n)});r&&n(r)},N.prototype.stat=function(t,n){n=z(n);var e=this,r=e.queueOrRun(function(){var r=e.provider.getReadWriteContext();W(r,e.name,t,n)});r&&n(r)},N.prototype.fstat=function(t,n){n=z(n);var e=this,r=e.queueOrRun(function(){var r=e.provider.getReadWriteContext();q(e,r,t,n)});r&&n(r)},N.prototype.link=function(t,n,e){e=z(e);var r=this,i=r.queueOrRun(function(){var i=r.provider.getReadWriteContext();H(i,t,n,e)});i&&e(i)},N.prototype.unl