/** @file\r
This file contains functions required to generate a Firmware File System file.\r
\r
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials \r
are licensed and made available under the terms and conditions of the BSD License \r
which accompanies this distribution. The full text of the license may be found at \r
);\r
}\r
\r
- if (EFI_ERROR (Status)) {\r
+ if (EFI_ERROR (Status) || (FileBuffer == NULL)) {\r
goto Finish;\r
}\r
\r
//\r
// Open output file to write ffs data.\r
//\r
- remove(OutputFileName);\r
- FfsFile = fopen (LongFilePath (OutputFileName), "wb");\r
- if (FfsFile == NULL) {\r
- Error (NULL, 0, 0001, "Error opening file", OutputFileName);\r
- goto Finish;\r
- }\r
- //\r
- // write header\r
- //\r
- fwrite (&FfsFileHeader, 1, HeaderSize, FfsFile);\r
- //\r
- // write data\r
- //\r
- fwrite (FileBuffer, 1, FileSize - HeaderSize, FfsFile);\r
+ if (OutputFileName != NULL) {\r
+ remove(OutputFileName);\r
+ FfsFile = fopen (LongFilePath (OutputFileName), "wb");\r
+ if (FfsFile == NULL) {\r
+ Error (NULL, 0, 0001, "Error opening file", OutputFileName);\r
+ goto Finish;\r
+ }\r
+ //\r
+ // write header\r
+ //\r
+ fwrite (&FfsFileHeader, 1, HeaderSize, FfsFile);\r
+ //\r
+ // write data\r
+ //\r
+ fwrite (FileBuffer, 1, FileSize - HeaderSize, FfsFile);\r
\r
- fclose (FfsFile);\r
+ fclose (FfsFile);\r
+ }\r
\r
Finish:\r
if (InputFileName != NULL) {\r