Stream Functions — This section describes functions to create streams to objects and how to use these streams.
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);
stream mapi_openpropertytostream(mapipropobj $mapiProp, ulong $propertytag, int $flags)
Opens a property to a stream object
![]() | 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.
The default access is read-only. Flags you can give:
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.
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)
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!");
string mapi_stream_read(stream $stream, int $lbytes)
Reads data from a stream
This functions read a specific ammount of data from a stream.
mapi_openpropertytostream, mapi_stream_stat, mapi_stream_write, mapi_stream_setsize, mapi_stream_seek
Example 3.59. Reading from a stream
$body = mapi_stream_read($stream, 100); echo $body; // will echo the first 100 bytes of the body
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.
A flag that can be given:
TThe new seek pointer is an offset relative to the beginning of the stream.
The new seek pointer is an offset relative to the current seek pointer location.
The new seek pointer is an offset relative to the end of the stream.
mapi_openpropertytostream, mapi_stream_stat, mapi_stream_write, mapi_stream_setsize, mapi_stream_read
Example 3.60. Seeking in a stream
mapi_stream_seek($stream, 100); // will move the pointer 100 bytes
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.
mapi_openpropertytostream, mapi_stream_stat, mapi_stream_write, mapi_stream_commit, mapi_stream_read
Example 3.61. Setting the size of a stream
mapi_stream_setsize($stream, 100); // will resize the stream to a size of 100 bytes
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.
mapi_openpropertytostream, mapi_stream_stat, mapi_stream_write, mapi_stream_setsize, mapi_stream_read
Example 3.62. Committing a stream
mapi_stream_commit($stream); // commit the stream, all data is saved.
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.
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.
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.
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.