Name

Stream Functions — This section describes functions to create streams to objects and how to use these streams.

Synopsis

stream mapi_openpropertytostream(mapipropobj $mapiProp,
                                 ulong $propertytag,
                                 int $flags);

resource mapi_stream_create();
string mapi_stream_read(stream $stream,
                        int $lbytes);

boolean mapi_stream_seek(stream $stream,
                         int $bytes,
                         int $flags);

boolean mapi_stream_setsize(stream $stream,
                            int $newsize);

boolean mapi_stream_commit(stream $stream);
boolean mapi_stream_write(stream $stream,
                          string $data);

array mapi_stream_stat(stream $stream);

Details

mapi_openpropertytostream ()

stream mapi_openpropertytostream(mapipropobj $mapiProp, ulong $propertytag, int $flags)

Opens a property to a stream object

[Warning]Warning
(DEPRECATED: use mapi_openproperty instead)

This functions opens a stream on a specific property. It returns a stream that can be used with other stream functions to read and write the data.

$mapiProp
A resource that is derived from MAPIProp.
$propertytag
The property that should be read.
$flags (optional)

The default access is read-only. Flags you can give:

MAPI_CREATE

If the property does not exist, it should be created. If the property does exist, the current value of the property should be discarded. When a caller sets the MAPI_CREATE flag, it should also set the MAPI_MODIFY flag.

MAPI_MODIFY

Requests read/write access to the property. The default access is read-only. MAPI_MODIFY must be set when MAPI_CREATE is set.

Example 3.57. Reading a stream

$bodyStream = mapi_openpropertytostream($message, PR_BODY);

$stat = mapi_stream_stat($bodyStream)
	  

mapi_stream_create ()

resource >mapi_stream_create()

Create a new in-memory stream object

This function can be used to create an in-memory stream object. Any data written to this object can subsequently be read from the same stream with mapi_stream_read().

Example 3.58. Creating a new stream

$stream = mapi_stream_create();
mapi_stream_write($stream, "Hello, world!");
	  

mapi_stream_read ()

string mapi_stream_read(stream $stream, int $lbytes)

Reads data from a stream

This functions read a specific ammount of data from a stream.

$stream
A resource that contains the stream. This resource is given back by mapi_openproperty()
$lbytes
The ammount of bytes that should be read.

Example 3.59. Reading from a stream

$body = mapi_stream_read($stream, 100);

echo $body;	// will echo the first 100 bytes of the body
	  

mapi_stream_seek ()

boolean mapi_stream_seek(stream $stream, int $bytes, int $flags)

Moves the internal pointer the given bytes.

This functions seek in a stream. It can move the pointer with the given bytes. The function will return true when the seeking was succesful or false when it wasn't. If no flag is given, STREAM_SEEK_CUR will be assumed.

$stream
A resource that contains the stream. This resource is given back by mapi_openproperty()
$bytes
The ammount of bytes the pointer should be moved.
$flags

A flag that can be given:

STREAM_SEEK_SET

TThe new seek pointer is an offset relative to the beginning of the stream.

STREAM_SEEK_CUR

The new seek pointer is an offset relative to the current seek pointer location.

STREAM_SEEK_END

The new seek pointer is an offset relative to the end of the stream.

Example 3.60. Seeking in a stream

mapi_stream_seek($stream, 100);	// will move the pointer 100 bytes
	  

mapi_stream_setsize ()

boolean mapi_stream_setsize(stream $stream, int $newsize)

Resizes a stream

This functions resizes the stream. With this function it is possible to preallocate space to use with the stream.

$stream
A resource that contains the stream. This resource is given back by mapi_openproperty()
$newsize
The new size of the stream in bytes.

Example 3.61. Setting the size of a stream

mapi_stream_setsize($stream, 100);	// will resize the stream to a size of 100 bytes
	  

mapi_stream_commit ()

boolean mapi_stream_commit(stream $stream)

Commits the stream

This functions commits the stream. Now all changes are saved. Will return true when everything is oke or false when an error has occured.

$stream
A resource that contains the stream. This resource is given back by mapi_openproperty()

Example 3.62. Committing a stream

mapi_stream_commit($stream);	// commit the stream, all data is saved.
	  

mapi_stream_write ()

boolean mapi_stream_write(stream $stream, string $data)

Write data to a stream

This functions writes data to the stream. The pointer will also moved the places that is needed. Use mapi_stream_commit to save the stream.

$stream
A resource that contains the stream. This resource is given back by mapi_openproperty()
$data
The bytes that should be written into the stream.

Example 3.63. Writing data into a stream

mapi_stream_write($stream, "data");	// will write "data" into the stream and moves the pointer 4 bytes.
	  

mapi_stream_stat ()

array mapi_stream_stat(stream $stream)

Gets the statistics of the stream.

This functions reads the statistics from a stream and returns this in an assoc array. For now only the element 'cb' is supported, this gives the size of the stream.

$stream
A resource that contains the stream. This resource is given back by mapi_openproperty()

Example 3.64. Getting the statistics from a stream

$stat = mapi_stream_stat($stream);

echo "Size :" . $stat['cb'];
// will read the stats from the stream.