primitiveAsyncFileWriteStart(void) { // AsynchFilePlugin>>#primitiveAsyncFileWriteStart sqInt buffer; sqInt bufferPtr; sqInt bufferSize; sqInt count; AsyncFile *f; sqInt fHandle; sqInt fPosition; sqInt num; sqInt start; sqInt startIndex; fHandle = stackValue(4); fPosition = stackIntegerValue(3); buffer = stackValue(2); start = stackIntegerValue(1); num = stackIntegerValue(0); if (failed()) { return null; } f = asyncFileValueOf(fHandle); if (failed()) { return null; } count = num; startIndex = start; /* in bytes or words */ bufferSize = slotSizeOf(buffer); if (isWords(buffer)) { /* covert word counts to byte counts */ /* covert word counts to byte counts */ count = count * 4; startIndex = ((startIndex - 1) * 4) + 1; bufferSize = bufferSize * 4; } success((startIndex >= 1) && (((startIndex + count) - 1) <= bufferSize)); /* adjust for zero-origin indexing */ bufferPtr = ((((int) (firstIndexableField(buffer)))) + startIndex) - 1; if (!(failed())) { asyncFileWriteStart(f, fPosition, bufferPtr, count); } if (failed()) { return null; } pop(5); return null; }
EXPORT(sqInt) primitiveAsyncFileWriteStart(void) { AsyncFile * f; sqInt count; sqInt startIndex; sqInt bufferSize; char * bufferPtr; sqInt fHandle; sqInt fPosition; sqInt buffer; sqInt start; sqInt num; fHandle = interpreterProxy->stackValue(4); fPosition = interpreterProxy->stackIntegerValue(3); buffer = interpreterProxy->stackValue(2); start = interpreterProxy->stackIntegerValue(1); num = interpreterProxy->stackIntegerValue(0); if (interpreterProxy->failed()) { return null; } f = asyncFileValueOf(fHandle); if (interpreterProxy->failed()) { return null; } count = num; startIndex = start; /* in bytes or words */ bufferSize = interpreterProxy->slotSizeOf(buffer); if (interpreterProxy->isWords(buffer)) { /* convert word counts to byte counts */ count = count * ( 4); startIndex = ((startIndex - 1) * ( 4)) + 1; bufferSize = bufferSize * ( 4); } interpreterProxy->success((startIndex >= 1) && (((startIndex + count) - 1) <= bufferSize)); bufferPtr = (((pointerForOop(buffer)) + ( 4)) + startIndex) - 1; if (!(interpreterProxy->failed())) { asyncFileWriteStart(f, fPosition, bufferPtr, count); } if (interpreterProxy->failed()) { return null; } interpreterProxy->pop(5); return null; }