logger.debug('Extract ffs data is saved in {}.'.format(outputfile))\r
else:\r
logger.error('Target Ffs/Fv not found!!!')\r
+\r
+def ShrinkFv(inputfile: str, outputfile: str) -> None:\r
+ if not os.path.exists(inputfile):\r
+ logger.error("Invalid inputfile, can not open {}.".format(inputfile))\r
+ raise Exception("Process Failed: Invalid inputfile!")\r
+ # 1. Data Prepare\r
+ with open(inputfile, "rb") as f:\r
+ whole_data = f.read()\r
+ FmmtParser = FMMTParser(inputfile, ROOT_TREE)\r
+ # 2. DataTree Create\r
+ logger.debug('Parsing inputfile data......')\r
+ FmmtParser.ParserFromRoot(FmmtParser.WholeFvTree, whole_data)\r
+ logger.debug('Done!')\r
+ TargetFv = FmmtParser.WholeFvTree.Child[0]\r
+ if TargetFv:\r
+ FvMod = FvHandler(TargetFv)\r
+ Status = FvMod.ShrinkFv()\r
+ else:\r
+ logger.error('Target Fv not found!!!')\r
+ # 4. Data Encapsulation\r
+ if Status:\r
+ logger.debug('Start encapsulating data......')\r
+ FmmtParser.Encapsulation(FmmtParser.WholeFvTree, False)\r
+ with open(outputfile, "wb") as f:\r
+ f.write(FmmtParser.FinalData)\r
+ logger.debug('Encapsulated data is saved in {}.'.format(outputfile))\r