Windows: when overwriting an existing file container, add its current size to the available free space

This commit is contained in:
Mounir IDRASSI 2023-07-11 21:21:18 +02:00
parent b1f578f0ef
commit 014ed77130
No known key found for this signature in database
GPG Key ID: 02C30AE90FAE4A6F
1 changed files with 7 additions and 0 deletions

View File

@ -3462,6 +3462,13 @@ BOOL QueryFreeSpace (HWND hwndDlg, HWND hwndTextBox, BOOL display, LONGLONG *pFr
else
{
LARGE_INTEGER lDiskFree;
// if the file pointed by szFileName already exists, we must add its size to the free space since it will be overwritten durig the volume creation
__int64 lFileSize = GetFileSize64(szFileName);
if (lFileSize != -1)
{
free.QuadPart += lFileSize;
}
lDiskFree.QuadPart = free.QuadPart;
if (pFreeSpaceValue)