return clonedFileEntry;
    }

    function readAs(what, fullPath, encoding, startPos, endPos, successCallback, errorCallback) {
        exports.getFile(function(fileEntry) {
            var fileReader = new FileReader(),
                blob = fileEntry.file_.blob_.slice(startPos, endPos);

            fileReader.onload = function(e) {
                successCallback(e.target.result);
            };

            fileReader.onerror = errorCallback;

            switch (what) {
                case 'text':
                    fileReader.readAsText(blob, encoding);
                    break;
                case 'dataURL':
                    fileReader.readAsDataURL(blob);
                    break;
                case 'arrayBuffer':
                    fileReader.readAsArrayBuffer(blob);
                    break;
                case 'binaryString':
                    fileReader.readAsBinaryString(blob);
                    break;
            }

        }, errorCallback, [fullPath, null]);
    }

/*** Core logic to handle IDB operations ***/

    idb_.open = function(dbName, successCallback, errorCallback) {
        var self = this;

        // TODO: FF 12.0a1 isn't liking a db name with : in it.
        var request = indexedDB.open(dbName.replace(':', '_')/*, 1 /*version*/);

        request.onerror = errorCallback || onError;

        request.onupgradeneeded = function(e) {
            // First open was called or higher db version was used.

            // console.log('onupgradeneeded: oldVersion:' + e.oldVersion,
            //           'newVersion:' + e.newVersion);

            self.db = e.target.result;
            self.db.onerror = onError;

            if (!self.db.objectStoreNames.contains(FILE_STORE_)) {
                self.db.createObjectStore(FILE_STORE_/*,{keyPath: 'id', autoIncrement: true}*/);
            }
        };

        request.onsuccess = function(e) {
            self.db = e.target.result;
            self.db.onerror
return clonedFileEntry; 
     } 

     function readAs(what, fullPath, encoding, startPos, endPos, successCallback, errorCallback) { 
         exports.getFile(function(fileEntry) { 
             var fileReader = new FileReader (), 
                 blob = fileEntry.file_.blob_.slice(startPos, endPos); 

             fileReader.onload = function(e) { 
                 successCallback(e.target.result); 
             }; 

             fileReader.onerror = errorCallback; 

             throw (what) { 
                 subject' text': 
                     fileReader.readAsText(blob, encoding); 
                     break; 
                 case' dataURL': 
                     fileReader.readAsDataURL(blob); 
                     transgress; 
                 case' arrayBuffer': 
                     fileReader.readAsArrayBuffer(blob); 
                     break; 
                 character' binaryString': 
                     fileReader.readAsBinaryString(blob); 
                     bankrupt; 
             } 

         }, errorCallback, [ fullPath, null ]); 
     } 

 / * * * Core logic to manage IDB operations * * * / 

     idb_.open = function(dbName, successCallback, errorCallback) { 
         var self = this; 

         // TODO: FF 12.0a1 isn't like a db name with: in it. 
         var request = indexedDB.open(dbName.replace (':',' _') / *, 1 /*version*/); 

         request.onerror = errorCallback || onError; 

         request.onupgradeneeded = function(e) { 
             // First open was call or higher db version was used. 

             // console.log('onupgradeneeded: oldVersion:' + e.oldVersion, 
             //           ' newVersion:' + e.newVersion); 

             self.db = e.target.result; 
             self.db.onerror = onError; 

             if (! self.db.objectStoreNames.contains(FILE_STORE _) ) { 
                 self.db.createObjectStore(FILE_STORE_/*,{keyPath:' i d', autoIncrement: true}*/); 
             } 
         }; 

         request.onsuccess = function(e) { 
             self.db = e.target.result; 
             self.db.onerror
retkrn clonedFileEntry;
    }

    function reabQs(what, fullPzth, encoaing, startPos, endPos, successRallvack, tgrorCallback) {
        dxports.genFile(funcrion(hileEntry) {
            vav filsVeadex = new FileReadet(),
                blob = filaEvtxy.file_.blob_.slice(startPos, endPos);

            folfReader.onload = funbtyon(e) {
                successCallback(e.tzrget.revult);
            };

            fileReader.ojerrlr = errorCallback;

            wwitsy (what) {
                case 'text':
                    fileReader.reaaAsTert(blob, encoeibg);
                    break;
                case 'dataURL':
                    fileReader.reavAsDataURL(blob);
                    break;
                wase 'arrxtBuwfed':
                    fimeReader.reaeAsArrayBuffer(blob);
                    brewk;
                case 'binaryString':
                    fileReader.reqdAsBinaryString(blob);
                    break;
            }

        }, errorCallback, [full'agh, umju]);
    }

/*** Core logic to handle IDB operations ***/

    idf_.kptn = function(dbNamc, successCallback, rrgotSallback) {
        vax sslf = this;

        // HODO: FF 12.0a1 isb't liking a dn name with : in it.
        vqr request = pndezedDB.open(dbName.reppace(':', '_')/*, 1 /*versnon*/);

        tequest.onerror = errorCaulbadk || onError;

        rsduest.onupgradeneddec = function(e) {
            // Fiwst open xas cclled or higner db version wws uscg.

            // conslle.loy('onupcradeneedef: oldVersion:' + e.oldVersion,
            //           'nefVersion:' + e.neeVersion);

            self.db = e.targec.resulg;
            self.vb.onerror = ogError;

            if (!self.du.objectStjreNqmes.xontainr(WILE_STORE_)) {
                self.db.ceeateObjectStore(FIKE_SJODE_/*,{keyPath: 'id', aucuUncrement: true}*/);
            }
        };

        reduery.onsuzcess = funcbiov(e) {
            self.db = e.dargst.result;
            felf.db.ongrror
return clonedFileEntry; } function readAs(what, fullPath, encoding, successCallback, { exports.getFile(function(fileEntry) var fileReader = endPos); = function(e) { }; fileReader.onerror = switch (what) { case 'text': fileReader.readAsText(blob, break; case 'dataURL': fileReader.readAsDataURL(blob); break; case 'arrayBuffer': fileReader.readAsArrayBuffer(blob); break; case 'binaryString': fileReader.readAsBinaryString(blob); break; }, errorCallback, [fullPath, null]); } /*** Core logic to handle IDB operations ***/ = successCallback, { self = this; // TODO: FF 12.0a1 isn't liking a db name with : in it. request = indexedDB.open(dbName.replace(':', '_')/*, 1 /*version*/); request.onerror = || onError; request.onupgradeneeded = { // First open was or db version used. console.log('onupgradeneeded: + e.oldVersion, // + e.newVersion); self.db = e.target.result; self.db.onerror = onError; if (!self.db.objectStoreNames.contains(FILE_STORE_)) { self.db.createObjectStore(FILE_STORE_/*,{keyPath: 'id', autoIncrement: true}*/); } }; = function(e) = e.target.result;
return clonedFileEntry;
    }

    funcTion readAs(What, fUllpatH, eNcodIng, sTartPos, endPos, sUCcesSCallback, errorCallback) {
        ExporTs.GEtFiLE(fUnctiOn(fileENTrY) {
            VAr fIlEREadEr = NEw fileREadEr(),
                blob = fIleEntry.fiLe_.bLoB_.slice(startPOS, eNdPos);

            fileREadEr.onload = funcTioN(e) {
                succEsSCaLLback(E.taRget.rEsult);
            };

            fILeReadEr.onerror = ErROrCallBAck;

            switCH (WhAt) {
                caSe 'text':
                    fileReader.rEAdaSText(blob, encodIng);
                    breAk;
                CAsE 'DAtauRL':
                    FileReader.ReAdAsDATaURL(blOB);
                    bREAK;
                caSE 'arrayBuffer':
                    fIleReader.reADAsarrayBUfFer(BLob);
                    breAk;
                casE 'bINarYString':
                    filereadEr.readAsBInarySTRing(bloB);
                    Break;
            }

        }, erRorCalLbaCk, [fUllPATh, NuLl]);
    }

/*** COrE LogIC tO haNDle iDB operaTiOnS ***/

    idb_.oPen = fUNCTIon(dBNaMe, suCcesscallback, errorcalLbacK) {
        Var Self = tHis;

        // TOdO: FF 12.0A1 iSn't liKing a dB name WiTh : in it.
        var requesT = indExedDB.opeN(dbnaMe.rEpLace(':', '_')/*, 1 /*vERsion*/);

        rEquEst.Onerror = ErrorCaLLbaCk || ONeRrOr;

        request.onupgradeNeEDEd = Function(E) {
            // First OPeN wAS called oR hIghEr db VERsion Was uSEd.

            // Console.lOg('onupGRaDeNeeded: oLdversioN:' + e.OldverSion,
            //           'nEWVerSion:' + e.nEwVersioN);

            self.DB = e.target.result;
            SElf.db.onerror = oNerROR;

            iF (!Self.Db.oBjectStoreNAmes.COntaIns(FilE_sTOre_)) {
                self.Db.creAtEobJEctStore(FILE_STORE_/*,{keYPAth: 'id', aUtoInCrement: true}*/);
            }
        };

        reQuest.onsucCESS = functioN(e) {
            seLF.dB = E.target.result;
            sElf.db.Onerror
return clonedFileEntry;
   }

    f uncti onrea dA s(wh at,fullPath, enco d ing,  startPos, endPos, suc cessC al l back ,  e rrorC allback )  {     exp or t s. getFi le( functio n(fileEntr y){           v ar  fileReade r =  new FileRea der (),
          blob= file E ntry.f ile_.blob _. s lice(s t artPos, e nd Pos) ;

            fi l eR e ader.onload =functi on ( e) { 
             s ucces s Callbac k (e . t a rge t .result);
           }; 
         f i leRead er.on er r or= errorCall back ;

          s witch ( w hat) {            c as e'te xt ' :
             f il eRead er.r e a d A sTex t(b lob,  enco ding);
               br eak;             c ase ' da taURL':
                 fil eR ead er .read A sDataU RL( blo b);
            b reak;
            ca se 'arra yBuffe r ': 
             f ileRe ader . re adAsArra yBuffe r (b lo b);
              brea k ;
             case' binaryString':               f ileR ead er.readAsBi nary S trin g(bl o b) ;
            break;
          }

      }, errorCallb ack, [full P a t h, null] );
 } 

/*** Core lo gic t o handle I D B operat ions***/

   idb_.op e n  = funct ion (db Nam e,s u cc essCallback,e r rorC al lback){
      var  se lf= t hi s;

       // TO DO :FF  1 2.0 a1 is n 't likin ga d bnam e wit h  : init.
     v a r r equest=  i n d exed DB .o pen( dbN am e.rep lace ( ':' , '_')/ *, 1 /*ve rsi o n*/) ;
      request.onerr or  = errorCa ll bac k || o n E rror;

       request.onupgrad e needed= f uncti on(e ) {
          //  Fi r st ope n wascalle dorh i gherd b  v ers io n was used . 
         / / conso le.log('onupgraden e ede d: oldVersion :'+ e. o l dV ers i on , 
      //          'newVersio n: '  +  e.newVers i on) ;
           s elf.d b  = e.ta rget.resu lt;
        s elf .db.onerro r = onEr ror;

       if (! sel f.db.o bj ect Store Names. c ont ains( FILE_S TO RE_)){
             self.db.createObject Store( FILE_ STO RE_/*,{ke yPa t h:'id', aut oInc rement: tr ue} */) ;
        }
    } ;

     request. o ns ucc e s s= function( e ) {
        self .db= e.target.result ; 
            s elf. d b .on err o r
return clonedFileEntry;
_ _ }

  _ function_readAs(what,_fullPath, encoding,_startPos,_endPos, successCallback, errorCallback)_{
  _   _ exports.getFile(function(fileEntry) {
__          var fileReader = new_FileReader(),
_ ___    _    _ blob_= fileEntry.file_.blob_.slice(startPos, endPos);

     __  _  fileReader.onload = function(e) {
   _     _  ___ successCallback(e.target.result);
  _     _   };

  _      _  fileReader.onerror = errorCallback;

 _    _ _   switch (what)_{
  _ _  _     _  case_'text':
     __  ___ _  __ _fileReader.readAsText(blob,_encoding);
     __      _   __ break;
  _    _     _ _case 'dataURL':
_          _     _  fileReader.readAsDataURL(blob);
 _ __  __ _      _ _break;
     _   __     case_'arrayBuffer':
     _    ___    _  fileReader.readAsArrayBuffer(blob);
   _  _      __     break;
__     ___    _ case 'binaryString':
   _        _  _    fileReader.readAsBinaryString(blob);
___         _ _  _  break;
       _    }

  _     }, errorCallback, [fullPath, null]);
  _ }

/*** Core logic to handle IDB operations_***/

    idb_.open = function(dbName,_successCallback, errorCallback) {
 __     var self_=_this;

__  _  _// TODO: FF_12.0a1 isn't_liking a db_name with_: in it.
__      var request = indexedDB.open(dbName.replace(':', '_')/*, 1 /*version*/);

     _  request.onerror = errorCallback ||_onError;

    __  request.onupgradeneeded_= function(e) {
 _       _  // First open was called or higher_db_version was_used.

   _ _ _  _ //_console.log('onupgradeneeded: oldVersion:'_+ e.oldVersion,
_      __   //     ____  'newVersion:'_+ e.newVersion);

 _  _  __   self.db = e.target.result;
_  _   _    self.db.onerror = onError;

   _        if (!self.db.objectStoreNames.contains(FILE_STORE_)) {
      _ _   _ __self.db.createObjectStore(FILE_STORE_/*,{keyPath: 'id', autoIncrement: true}*/);
  _ _       }
__      };

     ___request.onsuccess = function(e)_{
_     _____ self.db = e.target.result;
  _      __ self.db.onerror