[core] add and use WriteFileWithRetry() where possible

This commit is contained in:
Pete Batard 2016-01-14 17:43:02 +00:00
parent 2430c66a68
commit f2a539a48c
11 changed files with 123 additions and 109 deletions

View file

@ -2,8 +2,8 @@
* Rufus: The Reliable USB Formatting Utility
* DOS boot file extraction, from the FAT12 floppy image in diskcopy.dll
* (MS WinME DOS) or from the embedded FreeDOS resource files
* Copyright © 2011-2015 Pete Batard <pete@akeo.ie>
*
* Copyright © 2011-2016 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@ -257,8 +257,8 @@ static BOOL ExtractFAT(int entry, const char* path)
return FALSE;
}
if ((!WriteFile(hFile, &DiskImage[filestart], (DWORD)filesize, &Size, 0)) || (filesize != Size)) {
uprintf("Couldn't write file '%s': %s.\n", filename, WindowsErrorString());
if (!WriteFileWithRetry(hFile, &DiskImage[filestart], (DWORD)filesize, &Size, WRITE_RETRIES)) {
uprintf("Could not write file '%s': %s.\n", filename, WindowsErrorString());
safe_closehandle(hFile);
return FALSE;
}
@ -394,8 +394,8 @@ BOOL ExtractFreeDOS(const char* path)
return FALSE;
}
if ((!WriteFile(hFile, res_data, res_size, &Size, 0)) || (res_size != Size)) {
uprintf("Couldn't write file '%s': %s.\n", filename, WindowsErrorString());
if (!WriteFileWithRetry(hFile, res_data, res_size, &Size, WRITE_RETRIES)) {
uprintf("Could not write file '%s': %s.\n", filename, WindowsErrorString());
safe_closehandle(hFile);
return FALSE;
}