mirror of
https://github.com/AppleWin/AppleWin.git
synced 2025-01-08 13:31:00 +00:00
DiskImageHelper: small refactor
This commit is contained in:
parent
8ec8fa6c5b
commit
c280d43e75
@ -1414,7 +1414,7 @@ ImageError_e CImageHelperBase::CheckGZipFile(LPCTSTR pszImageFilename, ImageInfo
|
||||
|
||||
DWORD dwSize = nLen;
|
||||
DWORD dwOffset = 0;
|
||||
CImageBase* pImageType = Detect(pImageInfo->pImageBuffer, dwSize, szExt, dwOffset, pImageInfo->bWriteProtected, pImageInfo->pTrackMap, pImageInfo->optimalBitTiming, pImageInfo->maxNibblesPerTrack);
|
||||
CImageBase* pImageType = Detect(pImageInfo->pImageBuffer, dwSize, szExt, dwOffset, pImageInfo);
|
||||
|
||||
if (!pImageType)
|
||||
return eIMAGE_ERROR_UNSUPPORTED;
|
||||
@ -1505,7 +1505,7 @@ ImageError_e CImageHelperBase::CheckZipFile(LPCTSTR pszImageFilename, ImageInfo*
|
||||
|
||||
DWORD dwSize = nLen;
|
||||
DWORD dwOffset = 0;
|
||||
CImageBase* pImageType = Detect(pImageInfo->pImageBuffer, dwSize, szExt, dwOffset, pImageInfo->bWriteProtected, pImageInfo->pTrackMap, pImageInfo->optimalBitTiming, pImageInfo->maxNibblesPerTrack);
|
||||
CImageBase* pImageType = Detect(pImageInfo->pImageBuffer, dwSize, szExt, dwOffset, pImageInfo);
|
||||
|
||||
if (!pImageType)
|
||||
{
|
||||
@ -1602,7 +1602,7 @@ ImageError_e CImageHelperBase::CheckNormalFile(LPCTSTR pszImageFilename, ImageIn
|
||||
return eIMAGE_ERROR_BAD_SIZE;
|
||||
}
|
||||
|
||||
pImageType = Detect(pImageInfo->pImageBuffer, dwSize, szExt, dwOffset, pImageInfo->bWriteProtected, pImageInfo->pTrackMap, pImageInfo->optimalBitTiming, pImageInfo->maxNibblesPerTrack);
|
||||
pImageType = Detect(pImageInfo->pImageBuffer, dwSize, szExt, dwOffset, pImageInfo);
|
||||
if (bTempDetectBuffer)
|
||||
{
|
||||
delete [] pImageInfo->pImageBuffer;
|
||||
@ -1747,13 +1747,12 @@ CDiskImageHelper::CDiskImageHelper(void) :
|
||||
m_vecImageTypes.push_back( new CWOZ2Image );
|
||||
}
|
||||
|
||||
CImageBase* CDiskImageHelper::Detect(LPBYTE pImage, DWORD dwSize, const TCHAR* pszExt, DWORD& dwOffset,
|
||||
bool& writeProtected, BYTE*& pTrackMap, BYTE& optimalBitTiming, UINT& maxNibblesPerTrack)
|
||||
CImageBase* CDiskImageHelper::Detect(LPBYTE pImage, DWORD dwSize, const TCHAR* pszExt, DWORD& dwOffset, ImageInfo* pImageInfo)
|
||||
{
|
||||
dwOffset = 0;
|
||||
m_MacBinaryHelper.DetectHdr(pImage, dwSize, dwOffset);
|
||||
m_Result2IMG = m_2IMGHelper.DetectHdr(pImage, dwSize, dwOffset);
|
||||
maxNibblesPerTrack = NIBBLES_PER_TRACK; // Start with the default size (for all types). May get changed below.
|
||||
pImageInfo->maxNibblesPerTrack = NIBBLES_PER_TRACK; // Start with the default size (for all types). May get changed below.
|
||||
|
||||
// CALL THE DETECTION FUNCTIONS IN ORDER, LOOKING FOR A MATCH
|
||||
eImageType imageType = eImageUNKNOWN;
|
||||
@ -1798,14 +1797,14 @@ CImageBase* CDiskImageHelper::Detect(LPBYTE pImage, DWORD dwSize, const TCHAR* p
|
||||
|
||||
if (imageType == eImageWOZ1 || imageType == eImageWOZ2)
|
||||
{
|
||||
if (m_WOZHelper.ProcessChunks(pImage, dwSize, dwOffset, pTrackMap) != eMatch)
|
||||
if (m_WOZHelper.ProcessChunks(pImage, dwSize, dwOffset, pImageInfo->pTrackMap) != eMatch)
|
||||
return NULL;
|
||||
|
||||
// if (m_WOZHelper.IsWriteProtected() && !writeProtected) // Force write-protected until writing is supported
|
||||
writeProtected = true;
|
||||
// if (m_WOZHelper.IsWriteProtected() && !pImageInfo->writeProtected) // Force write-protected until writing is supported
|
||||
pImageInfo->bWriteProtected = true;
|
||||
|
||||
optimalBitTiming = m_WOZHelper.GetOptimalBitTiming();
|
||||
maxNibblesPerTrack = m_WOZHelper.GetMaxNibblesPerTrack();
|
||||
pImageInfo->optimalBitTiming = m_WOZHelper.GetOptimalBitTiming();
|
||||
pImageInfo->maxNibblesPerTrack = m_WOZHelper.GetMaxNibblesPerTrack();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1821,8 +1820,8 @@ CImageBase* CDiskImageHelper::Detect(LPBYTE pImage, DWORD dwSize, const TCHAR* p
|
||||
{
|
||||
pImageType->SetVolumeNumber( m_2IMGHelper.GetVolumeNumber() );
|
||||
|
||||
if (m_2IMGHelper.IsLocked() && !writeProtected)
|
||||
writeProtected = true;
|
||||
if (m_2IMGHelper.IsLocked() && !pImageInfo->bWriteProtected)
|
||||
pImageInfo->bWriteProtected = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1877,8 +1876,7 @@ CHardDiskImageHelper::CHardDiskImageHelper(void) :
|
||||
m_vecImageTypes.push_back( new CHDVImage );
|
||||
}
|
||||
|
||||
CImageBase* CHardDiskImageHelper::Detect(LPBYTE pImage, DWORD dwSize, const TCHAR* pszExt, DWORD& dwOffset,
|
||||
bool& writeProtected, BYTE*& pTrackMap, BYTE& optimalBitTiming, UINT& maxNibblesPerTrack)
|
||||
CImageBase* CHardDiskImageHelper::Detect(LPBYTE pImage, DWORD dwSize, const TCHAR* pszExt, DWORD& dwOffset, ImageInfo* pImageInfo)
|
||||
{
|
||||
dwOffset = 0;
|
||||
m_Result2IMG = m_2IMGHelper.DetectHdr(pImage, dwSize, dwOffset);
|
||||
@ -1903,14 +1901,14 @@ CImageBase* CHardDiskImageHelper::Detect(LPBYTE pImage, DWORD dwSize, const TCHA
|
||||
{
|
||||
if (m_Result2IMG == eMatch)
|
||||
{
|
||||
if (m_2IMGHelper.IsLocked() && !writeProtected)
|
||||
writeProtected = true;
|
||||
if (m_2IMGHelper.IsLocked() && !pImageInfo->bWriteProtected)
|
||||
pImageInfo->bWriteProtected = true;
|
||||
}
|
||||
}
|
||||
|
||||
pTrackMap = 0; // TODO: WOZ
|
||||
optimalBitTiming = 0; // TODO: WOZ
|
||||
maxNibblesPerTrack = 0; // TODO
|
||||
pImageInfo->pTrackMap = 0; // TODO: WOZ
|
||||
pImageInfo->optimalBitTiming = 0; // TODO: WOZ
|
||||
pImageInfo->maxNibblesPerTrack = 0; // TODO
|
||||
|
||||
return pImageType;
|
||||
}
|
||||
|
@ -307,7 +307,7 @@ public:
|
||||
ImageError_e Open(LPCTSTR pszImageFilename, ImageInfo* pImageInfo, const bool bCreateIfNecessary, std::string& strFilenameInZip);
|
||||
void Close(ImageInfo* pImageInfo, const bool bDeleteFile);
|
||||
|
||||
virtual CImageBase* Detect(LPBYTE pImage, DWORD dwSize, const TCHAR* pszExt, DWORD& dwOffset, bool& writeProtected, BYTE*& pTrackMap, BYTE& optimalBitTiming, UINT& maxNibblesPerTrack) = 0;
|
||||
virtual CImageBase* Detect(LPBYTE pImage, DWORD dwSize, const TCHAR* pszExt, DWORD& dwOffset, ImageInfo* pImageInfo) = 0;
|
||||
virtual CImageBase* GetImageForCreation(const TCHAR* pszExt, DWORD* pCreateImageSize) = 0;
|
||||
virtual UINT GetMaxImageSize(void) = 0;
|
||||
virtual UINT GetMinDetectSize(const UINT uImageSize, bool* pTempDetectBuffer) = 0;
|
||||
@ -352,7 +352,7 @@ public:
|
||||
CDiskImageHelper(void);
|
||||
virtual ~CDiskImageHelper(void) {}
|
||||
|
||||
virtual CImageBase* Detect(LPBYTE pImage, DWORD dwSize, const TCHAR* pszExt, DWORD& dwOffset, bool& writeProtected, BYTE*& pTrackMap, BYTE& optimalBitTiming, UINT& maxNibblesPerTrack);
|
||||
virtual CImageBase* Detect(LPBYTE pImage, DWORD dwSize, const TCHAR* pszExt, DWORD& dwOffset, ImageInfo* pImageInfo);
|
||||
virtual CImageBase* GetImageForCreation(const TCHAR* pszExt, DWORD* pCreateImageSize);
|
||||
virtual UINT GetMaxImageSize(void);
|
||||
virtual UINT GetMinDetectSize(const UINT uImageSize, bool* pTempDetectBuffer);
|
||||
@ -378,7 +378,7 @@ public:
|
||||
CHardDiskImageHelper(void);
|
||||
virtual ~CHardDiskImageHelper(void) {}
|
||||
|
||||
virtual CImageBase* Detect(LPBYTE pImage, DWORD dwSize, const TCHAR* pszExt, DWORD& dwOffset, bool& writeProtected, BYTE*& pTrackMap, BYTE& optimalBitTiming, UINT& maxNibblesPerTrack);
|
||||
virtual CImageBase* Detect(LPBYTE pImage, DWORD dwSize, const TCHAR* pszExt, DWORD& dwOffset, ImageInfo* pImageInfo);
|
||||
virtual CImageBase* GetImageForCreation(const TCHAR* pszExt, DWORD* pCreateImageSize);
|
||||
virtual UINT GetMaxImageSize(void);
|
||||
virtual UINT GetMinDetectSize(const UINT uImageSize, bool* pTempDetectBuffer);
|
||||
|
Loading…
Reference in New Issue
Block a user