processBookIntoStringBuffer method

Future<String> processBookIntoStringBuffer(
  1. EpubBookRef? book,
  2. bool isVertical,
  3. int fileSize
)

Implementation

Future<String> processBookIntoStringBuffer(EpubBookRef? book, bool isVertical, int fileSize ) async {
  //  CHECK IF HTML STORAGE FILE EXISTS - title == filename
  var result = await storageUtil.checkForExistingHtmlFiles(title);

  if (result) {
    //  THE HTML FILE EXISTS DECRYPT AND RETURN
    var htmlString = await storageUtil.decryptDecompressEpub(title, isVertical);
    return htmlString;
  }else{
    //  CREATE NEW HTML FILE AND SAVE ACCORDINGLY
    var openedEbook = '';
    if (isVertical) {
      //  EMPLOY VERTICAL BUFFER
      openedEbook = await buildStringBuffer(book!);
      bookContents = openedEbook;
    }else{
      //  EMPLOY HORIZONTAL BUFFER
      openedEbook = await buildStringBufferForHorizontal(book!);
      bookContents = openedEbook;
    }// end if-else

    //  SAVE HTML FILE TO LOCAL STORAGE OR CACHE
    // await EncryptionUtils.initialize();
    // await EncryptionUtils.encryptAndSaveFile(openedEbook, title, fileSize);
    await storageUtil.saveEncryptedCompressedEpub(openedEbook, title, fileSize);
    //  RETRIEVE SAVED HTML FILE
    var resultant = await storageUtil.decryptDecompressEpub(title, isVertical);
    return resultant;
  }// end if else
}