- 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