public void RopCopyToStreamMethod(bool isDestinationExist, out bool isReadWriteSuccess, out CPRPTErrorCode error)
{
isReadWriteSuccess = false;
error = CPRPTErrorCode.None;
// The source handle.
uint firstHandle = this.cprptFirstHandle;
// The destination handle.
uint secondHandle = InvalidHandle;
if (isDestinationExist)
{
secondHandle = this.cprptSecondHandle;
}
RopGetStreamSizeResponse getStreamSizeRes = this.RopGetStreamSize(firstHandle, true);
ulong byteCount = getStreamSizeRes.StreamSize;
// Set position of the source handle to the beginning of stream.
this.RopSeekStream(firstHandle, (byte)Origin.Beginning, ConstValues.RopSeekStreamOffsetZero, true);
if (isDestinationExist)
{
// Set position of the destination handle to the beginning of stream.
this.RopSeekStream(secondHandle, (byte)Origin.Beginning, ConstValues.RopSeekStreamOffsetZero, true);
}
RopCopyToStreamResponse copyToStreamResponse = this.RopCopyToStream(firstHandle, secondHandle, (byte)HandleIndex.FirstIndex, (byte)HandleIndex.SecondIndex, byteCount);
bool isCopyRightDataCount = false;
if (isDestinationExist)
{
isCopyRightDataCount = byteCount == copyToStreamResponse.WrittenByteCount;
}
bool destHandleIsRight = false;
if (copyToStreamResponse.ReturnValue.Equals((uint)CPRPTErrorCode.NullDestinationObject))
{
destHandleIsRight = copyToStreamResponse.DestHandleIndex == (uint)HandleIndex.SecondIndex;
}
this.VerifyRopCopyToStream(copyToStreamResponse, isDestinationExist, isCopyRightDataCount, destHandleIsRight);
if (copyToStreamResponse.ReturnValue == (uint)CPRPTErrorCode.None)
{
isReadWriteSuccess = true;
}
if (copyToStreamResponse.ReturnValue == (uint)CPRPTErrorCode.NullDestinationObject)
{
isReadWriteSuccess = false;
error = CPRPTErrorCode.NullDestinationObject;
}
}