EFI_USER_INTERFACE_SECTION *UiSect;\r
UINT32 InputLength;\r
UINT8 *OutFileBuffer;\r
- UINT8 *TempBuffer;\r
- UINT32 TempLength;\r
EFI_STATUS Status;\r
UINT64 LogLevel;\r
\r
SectGuidHeaderLength = 0;\r
VersionSect = NULL;\r
UiSect = NULL;\r
- TempBuffer = NULL;\r
\r
SetUtilityName (UTILITY_NAME);\r
\r
if (SectType != EFI_SECTION_ALL) {\r
InputLength = SECTION_SIZE (OutFileBuffer);\r
}\r
+ \r
//\r
- // Write the Buffer to the Output file.\r
+ // Write the output file\r
//\r
- OutFile = fopen (OutputFileName, "rb");\r
- if (OutFile != NULL) {\r
- //\r
- // the output file exists\r
- // first compare the output buffer and the exist output file \r
- // if same, not to update output file\r
- //\r
- fseek (OutFile, 0, SEEK_END);\r
- TempLength = ftell (OutFile);\r
- fseek (OutFile, 0, SEEK_SET);\r
-\r
- if (InputLength != TempLength) {\r
- //\r
- // they can't be same because their size are different\r
- //\r
- goto WriteFile;\r
- }\r
- //\r
- // read file data from output file\r
- //\r
- TempBuffer = (UINT8 *) malloc (TempLength);\r
- if (TempBuffer == NULL) {\r
- Error (NULL, 0, 4001, "Resource", "memory cannot be allcoated");\r
- goto Finish;\r
- }\r
- fread (TempBuffer, TempLength, 1, OutFile);\r
- //\r
- // Compare Data byte by byte\r
- //\r
- for (Index = 0; Index < InputLength; Index ++) {\r
- if (OutFileBuffer [Index] != TempBuffer [Index]) {\r
- break;\r
- }\r
- }\r
- //\r
- // Data is same, output file doesn't need to be updated.\r
- //\r
- if (Index >= InputLength) {\r
- goto Finish;\r
- }\r
- }\r
-\r
-WriteFile:\r
- if (OutFile != NULL) {\r
- fclose (OutFile);\r
- }\r
-\r
OutFile = fopen (OutputFileName, "wb");\r
if (OutFile == NULL) {\r
Error (NULL, 0, 0001, "Error opening file for writing", OutputFileName);\r
if (InputFileName != NULL) {\r
free (InputFileName);\r
}\r
- \r
- if (TempBuffer != NULL) {\r
- free (TempBuffer);\r
- }\r
\r
if (OutFileBuffer != NULL) {\r
free (OutFileBuffer);\r