Table of Contents

OIL2 Class Standard.SendFile


class Standard . SendFile {
        int32   blockSize;
        int32   bytesCopied;
        oid     client;
        oid     destObj;
        int32   maxBytes;
        int32   sawEOF;
        oid     srcObj;
inherits from Object;

DESCRIPTION

The class SendFile is a helper application that efficiently copies streams of data from one IOobject to another. The primary benefits of using SendFile are that

METHODS


Standard.SendFile:create

SendFile:create(oid src, oid dest, optional int32 maxBytesToCopy, optional int32 maxBlockSize)

Method Description

The src and dest arguments are mandatory and identify objects allomorphic to IOobject. The src object will be sent selectForRead, readBytes and closeForRead methods. The dest object is sent writeBytes messages. When end-of-file is encountered while reading from the src object, it will be sent a IOobject:closeForRead message. If the src object was previously sent a IOobject:setDeleteOnClose message, it will be automatically deleted.

Sometimes, an predetermined number of bytes should be read from the src object. This functionality is enabled by providing the required number of bytes as the optional argument maxBytesToCopy. If this argument is used and not specified as -1, then the transfer is stopped after the exact number of bytes. In contrast to normal operation, a IOobject:closeForRead message is not sent to the src object.

The maximum size of the read blocks can be set using the optional argument maxBlockSize. Normally, this is not set and the system default maximum buffer size is used (made avaiable as the system information attribute IOmaxReadBuffer).


Standard.SendFile:getBytesCopied

SendFile:getBytesCopied()

Method Description

When the data transfer operation is completed, the getBytesCopied method returns the number of bytes copied. If the transfer operation is in progress at the time getBytesCopied is invoked, the return of the result will be delayed until the copy is complete.

Return Value

Returns an integer indicating the number of bytes that were copied.