[core] speed up the clearing of MBR/GPT sectors

* write_sector() should really only be used when writing single sectors as it
  is way to slow for anything else => Switch to using WriteFileWithRetry().
* Also revert an unwarranted change from f0047986e7.
This commit is contained in:
Pete Batard 2021-09-19 14:29:30 +01:00
parent f0047986e7
commit 9dc045a701
No known key found for this signature in database
GPG key ID: 38E0CF5E69EDD671
5 changed files with 27 additions and 26 deletions

View file

@ -855,6 +855,10 @@ BOOL WriteFileWithRetry(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWr
DWORD nTry;
BOOL readFilePointer;
LARGE_INTEGER liFilePointer, liZero = { { 0,0 } };
DWORD NumberOfBytesWritten;
if (lpNumberOfBytesWritten == NULL)
lpNumberOfBytesWritten = &NumberOfBytesWritten;
// Need to get the current file pointer in case we need to retry
readFilePointer = SetFilePointerEx(hFile, liZero, &liFilePointer, FILE_CURRENT);