MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / PutFileImage

Function PutFileImage

BaseTools/Source/C/Common/CommonLib.c:258–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

256}
257
258EFI_STATUS
259PutFileImage (
260 IN CHAR8 *OutputFileName,
261 IN CHAR8 *OutputFileImage,
262 IN UINT32 BytesToWrite
263 )
264/*++
265
266Routine Description:
267
268 This function opens a file and writes OutputFileImage into the file.
269
270Arguments:
271
272 OutputFileName The name of the file to write.
273 OutputFileImage A pointer to the memory buffer.
274 BytesToWrite The size of the memory buffer.
275
276Returns:
277
278 EFI_SUCCESS The function completed successfully.
279 EFI_INVALID_PARAMETER One of the input parameters was invalid.
280 EFI_ABORTED An error occurred.
281 EFI_OUT_OF_RESOURCES No resource to complete operations.
282
283--*/
284{
285 FILE *OutputFile;
286 UINT32 BytesWrote;
287
288 //
289 // Verify input parameters.
290 //
291 if (OutputFileName == NULL || strlen (OutputFileName) == 0 || OutputFileImage == NULL) {
292 return EFI_INVALID_PARAMETER;
293 }
294 //
295 // Open the file and copy contents into a memory buffer.
296 //
297 //
298 // Open the file
299 //
300 OutputFile = fopen (LongFilePath (OutputFileName), "wb");
301 if (OutputFile == NULL) {
302 Error (NULL, 0, 0001, "Error opening the output file", OutputFileName);
303 return EFI_ABORTED;
304 }
305
306 //
307 // Write all of the file contents.
308 //
309 BytesWrote = fwrite (OutputFileImage, sizeof (UINT8), BytesToWrite, OutputFile);
310 if (BytesWrote != sizeof (UINT8) * BytesToWrite) {
311 Error (NULL, 0, 0002, "Error writing the output file", OutputFileName);
312 fclose (OutputFile);
313 return EFI_ABORTED;
314 }
315 //

Callers 1

ParseSectionFunction · 0.85

Calls 6

fopenFunction · 0.85
fwriteFunction · 0.85
fcloseFunction · 0.85
LongFilePathFunction · 0.70
ErrorFunction · 0.70
strlenFunction · 0.50

Tested by

no test coverage detected