Allow files larger than 16MB to be added to HFS volumes

Ideally this would add a "what's your limit" call to the disk image
library, but this will do for now.
This commit is contained in:
Andy McFadden 2020-03-26 11:08:24 -07:00
parent 8ecb8e35eb
commit 8d5e07e683
2 changed files with 19 additions and 8 deletions

View File

@ -1581,14 +1581,15 @@ CString DiskArchive::ProcessFileAddData(DiskFS* pDiskFS, int addOptsConvEOL)
else
convHA = GenericEntry::kConvertHAOff;
errMsg = LoadFile(pDataDetails->GetLocalPathName(), &dataBuf, &dataLen,
convEOL, convHA);
errMsg = LoadFile(pDataDetails->GetLocalPathName(), pDiskFS,
&dataBuf, &dataLen, convEOL, convHA);
if (!errMsg.IsEmpty())
goto bail;
}
if (pRsrcDetails != NULL) {
/* no text conversion on resource forks */
errMsg = LoadFile(pRsrcDetails->GetLocalPathName(), &rsrcBuf, &rsrcLen,
errMsg = LoadFile(pRsrcDetails->GetLocalPathName(), pDiskFS,
&rsrcBuf, &rsrcLen,
GenericEntry::kConvertEOLOff, GenericEntry::kConvertHAOff);
if (!errMsg.IsEmpty())
goto bail;
@ -1624,7 +1625,10 @@ bail:
// TODO: really ought to update the progress counter, especially when reading
// really large files.
CString DiskArchive::LoadFile(const WCHAR* pathName, uint8_t** pBuf, long* pLen,
// TODO: shouldn't be loading really large files into memory. ProDOS is fine
// (16MB limit), HFS could be problematic in a 32-bit app.
CString DiskArchive::LoadFile(const WCHAR* pathName, DiskFS* pDiskFS,
uint8_t** pBuf, long* pLen,
GenericEntry::ConvertEOL conv, GenericEntry::ConvertHighASCII convHA) const
{
const char kCharLF = '\n';
@ -1666,8 +1670,15 @@ CString DiskArchive::LoadFile(const WCHAR* pathName, uint8_t** pBuf, long* pLen,
*pBuf = NULL;
*pLen = 0;
goto bail;
} else if (fileLen > 0x00ffffff) {
errMsg = L"Cannot add files larger than 16MB to a disk image.";
}
// TODO: we want to limit the file length based on the filesystem type,
// so we don't initiate an operation that can't possibly succeed. We
// should be able to query the DiskImg for its max file size, but that
// API doesn't currently exist. For now, limit anything other than HFS
// to 16MB.
if (pDiskFS->GetDiskImg()->GetFSFormat() != DiskImg::kFormatMacHFS &&
fileLen > 0x00ffffff) {
errMsg = L"Cannot add files larger than 16MB to a non-HFS disk image.";
goto bail;
}

View File

@ -358,7 +358,7 @@ private:
*
* Returns an empty string on success, or an error message on failure.
*/
CString LoadFile(const WCHAR* pathName, uint8_t** pBuf, long* pLen,
CString LoadFile(const WCHAR* pathName, DiskFS* pDiskFS, uint8_t** pBuf, long* pLen,
GenericEntry::ConvertEOL conv, GenericEntry::ConvertHighASCII convHA) const;
/*