GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



next up previous contents
Next: Seeking on a FileStream Up: The FileStream Package Previous: Reading from a FileStream   Contents

Writing to a FileStream Instance

As the class GATFileStream implements the interface GATInterface_IStreamable, writing to a GATFileStream is as easy as reading from a GATFileStream instance. To do so we need only make use of the utility function

GATResult GATStreamable_Write(GATObject object, 
                              void *buffer,
                              GATuint32 size, 
                              GATuint32 *written_bytes)

The first argument to this function is a GATObject instance. This GATObject instance must realize the interface GATInterface_IStreamable. For our immediate goals this instance will always be an instance of a GATFileStream. The second argument to this function is a void * pointing to a buffer containing the data to be written. The next argument is a GATuint32, a GAT primitive type covered in Appendix [*], which passes to the function the length of the buffer in bytes. The final argument is a GATuint32 * which passes back to the caller the actual number of bytes written. Finally, this function returns a GATResult, covered in Appendix [*], which indicates the completion status of this function.

As a quick example let us write a buffer buffer filled with sizeBuffer bytes to a GATFileStream instance fileStream. Such a call would look as follows

void *buffer;
GATResult result;
GATObject object;
GATuint32 bufferSize;
GATuint32 writtenBytes;
GATFileStream fileStream;

buffer = ...
bufferSize = ...

fileStream = ...

object = GATFileStream_ToGATObject( fileStream );

result = GATStreamable_Write( object, buffer, bufferSize, &writtenBytes );

if( GAT_SUCCEEDED( result ) )
{
  /* Do something as writtenBytes of buffer have been written to fileStream */
}


next up previous contents
Next: Seeking on a FileStream Up: The FileStream Package Previous: Reading from a FileStream   Contents
Andre Merzky 2004-05-13