mirror of
https://github.com/AppleWin/AppleWin.git
synced 2024-10-21 02:24:34 +00:00
Fix: Previous commit broke growing of HDD images (normal file).
This commit is contained in:
parent
f49d2b4d6b
commit
8d8d2de5e1
@ -174,10 +174,11 @@ bool CImageBase::ReadBlock(ImageInfo* pImageInfo, const int nBlock, LPBYTE pBloc
|
||||
bool CImageBase::WriteBlock(ImageInfo* pImageInfo, const int nBlock, LPBYTE pBlockBuffer)
|
||||
{
|
||||
long Offset = pImageInfo->uOffset + nBlock * HD_BLOCK_SIZE;
|
||||
const bool bGrowImageBuffer = (UINT)Offset+HD_BLOCK_SIZE > pImageInfo->uImageSize;
|
||||
|
||||
if (pImageInfo->FileType == eFileGZip || pImageInfo->FileType == eFileZip)
|
||||
{
|
||||
if ((UINT)Offset+HD_BLOCK_SIZE > pImageInfo->uImageSize)
|
||||
if (bGrowImageBuffer)
|
||||
{
|
||||
// Horribly inefficient! (Unzip to a normal file if you want better performance!)
|
||||
const UINT uNewImageSize = Offset+HD_BLOCK_SIZE;
|
||||
@ -208,6 +209,9 @@ bool CImageBase::WriteBlock(ImageInfo* pImageInfo, const int nBlock, LPBYTE pBlo
|
||||
BOOL bRes = WriteFile(pImageInfo->hFile, pBlockBuffer, HD_BLOCK_SIZE, &dwBytesWritten, NULL);
|
||||
if (!bRes || dwBytesWritten != HD_BLOCK_SIZE)
|
||||
return false;
|
||||
|
||||
if (bGrowImageBuffer)
|
||||
pImageInfo->uImageSize += HD_BLOCK_SIZE;
|
||||
}
|
||||
else if (pImageInfo->FileType == eFileGZip)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user