/* Get the FFS file state by checking the highest bit set in the header's state field. */
EFI_FFS_FILE_STATE GetFileState(IN UINT8 ErasePolarity, IN EFI_FFS_FILE_HEADER *FfsHeader)
/* Get the FFS file state by checking the highest bit set in the header's state field. */
EFI_FFS_FILE_STATE GetFileState(IN UINT8 ErasePolarity, IN EFI_FFS_FILE_HEADER *FfsHeader)
{
  EFI_FFS_FILE_STATE  FileState;
  UINT8               HighestBit;
  FileState = FfsHeader->State;
  if (ErasePolarity != 0) {
    FileState = (EFI_FFS_FILE_STATE) ~FileState;
  }
  HighestBit = 0x80;
  while (HighestBit != 0 && ((HighestBit & FileState) == 0)) {
    HighestBit >>= 1;
  }
  return (EFI_FFS_FILE_STATE)HighestBit;
}