void VDFileAsyncNT::FastWrite(const void *pData, uint32 bytes) { if (mhFileFast == INVALID_HANDLE_VALUE) { if (pData) Write(mClientFastPointer, pData, bytes); else WriteZero(mClientFastPointer, bytes); } else { if (mpError) ThrowError(); uint32 bytesLeft = bytes; while(bytesLeft) { uint32 actual = mBufferSize - mBufferLevel; if (actual > bytesLeft) actual = bytesLeft; if (mWriteOffset + actual > mBufferSize) actual = mBufferSize - mWriteOffset; if (!actual) { mReadOccurred.wait(); if (mpError) ThrowError(); continue; } if (pData) { memcpy(&mBuffer[mWriteOffset], pData, actual); pData = (const char *)pData + actual; } else { memset(&mBuffer[mWriteOffset], 0, actual); } uint32 oldWriteOffset = mWriteOffset; mWriteOffset += actual; if (mWriteOffset >= mBufferSize) mWriteOffset = 0; mBufferLevel += actual; // only bother signaling if the write offset crossed a block boundary if (oldWriteOffset % mBlockSize + actual >= mBlockSize) { mWriteOccurred.signal(); if (mpError) ThrowError(); } bytesLeft -= actual; } } mClientFastPointer += bytes; }
LOCALPROC MakeNewDisk(ui5b L, char *drivepath) { blnr IsOk = falseblnr; FILE *refnum = fopen(drivepath, "wb+"); if (NULL == refnum) { MacMsg(kStrOpenFailTitle, kStrOpenFailMessage, falseblnr); } else { if (WriteZero(refnum, L)) { IsOk = Sony_Insert0(refnum, falseblnr, drivepath); refnum = NULL; } if (refnum != NULL) { fclose(refnum); } if (! IsOk) { (void) remove(drivepath); } } }
void VDFileAsync9x::FastWrite(const void *pData, uint32 bytes) { if (mhFileFast == INVALID_HANDLE_VALUE) { if (pData) Write(mClientFastPointer, pData, bytes); else WriteZero(mClientFastPointer, bytes); } else { if (mpError) ThrowError(); uint32 bytesLeft = bytes; while(bytesLeft) { int actual; void *p = mBuffer.LockWrite(bytesLeft, actual); if (!actual) { mReadOccurred.wait(); if (mpError) ThrowError(); continue; } if (pData) { memcpy(p, pData, actual); pData = (const char *)pData + actual; } else { memset(p, 0, actual); } mBuffer.UnlockWrite(actual); mWriteOccurred.signal(); bytesLeft -= actual; } } mClientFastPointer += bytes; }