CSFileStream
in package
implements
CSFileStreamInterface
Tags
Interfaces, Classes and Traits
- CSFileStreamInterface
- Defines the interface for a file stream API object to read meta-data information and read & write content as a stream.
Table of Contents
- __toString() : string
- Reads all data from the stream into a string, from the beginning to end.
- closeStream() : bool
- Closes the file stream API object.
- isEndOfStream() : bool
- Checks whether it is the end of the stream.
- isReadableStream() : bool
- Checks if the stream is readable.
- isSeekableStream() : bool
- Checks if the stream is seekable.
- isWritableStream() : bool
- Checks if the stream is writable.
- openStream() : void
- Opens the stream file.
- readStream() : string
- Reads the content of the stream with the given length.
- rewindStream() : void
- Rewinds the stream file API object.
- seekStream() : void
- Seeks the stream file API objects.
- setContentFromPath() : bool
- Sets the content from a given file path.
- setContentFromStream() : bool
- Sets the content from a given stream file API object.
- setContentFromString() : bool
- Sets the content from string content.
- streamContent() : void
- Streams the content for the given stream type.
- writeStream() : int|false
- Writes the given content to the file stream API object.
Methods
__toString()
Reads all data from the stream into a string, from the beginning to end.
public
__toString() : string
This method MUST attempt to seek to the beginning of the stream before reading data and read the stream until the end is reached.
Warning: This could attempt to load a large amount of data into memory.
This method MUST NOT raise an exception in order to conform with PHP's string casting operations.
Tags
Return values
string —closeStream()
Closes the file stream API object.
public
closeStream() : bool
Tags
Return values
bool —isEndOfStream()
Checks whether it is the end of the stream.
public
isEndOfStream() : bool
Tags
Return values
bool —isReadableStream()
Checks if the stream is readable.
public
isReadableStream() : bool
Tags
Return values
bool —isSeekableStream()
Checks if the stream is seekable.
public
isSeekableStream() : bool
Tags
Return values
bool —isWritableStream()
Checks if the stream is writable.
public
isWritableStream() : bool
Tags
Return values
bool —openStream()
Opens the stream file.
public
openStream(string $sMode) : void
Parameters
- $sMode : string
-
The target stream mode
Tags
Return values
void —readStream()
Reads the content of the stream with the given length.
public
readStream([int|null $iLength = null ]) : string
Parameters
- $iLength : int|null = null
Tags
Return values
string —rewindStream()
Rewinds the stream file API object.
public
rewindStream() : void
Tags
Return values
void —seekStream()
Seeks the stream file API objects.
public
seekStream(int $iOffset[, int $iWhence = SEEK_SET ]) : void
Parameters
- $iOffset : int
-
To move to a position before the end-of-file, you need to pass a negative value in offset and set whence to SEEK_END.
- $iWhence : int = SEEK_SET
-
Whence values are: SEEK_SET - Set position equal to offset bytes. SEEK_CUR - Set position to current location plus offset. SEEK_END - Set position to end-of-file plus offset. If whence is not specified, it is assumed to be SEEK_SET.
Tags
Return values
void —setContentFromPath()
Sets the content from a given file path.
public
final setContentFromPath(string $sFilePath) : bool
Parameters
- $sFilePath : string
-
The path of the file where we get the content to write.
Tags
Return values
bool —setContentFromStream()
Sets the content from a given stream file API object.
public
final setContentFromStream(CSFileStream $oFileStream) : bool
Parameters
- $oFileStream : CSFileStream
-
The stream file API object where we get the content to write.
Tags
Return values
bool —setContentFromString()
Sets the content from string content.
public
final setContentFromString(string $sContent) : bool
Parameters
- $sContent : string
-
The content, which should be set to the stream file API object
Tags
Return values
bool —streamContent()
Streams the content for the given stream type.
public
streamContent([int $iStreamType = self::STREAM_TYPE_PRINT_AND_DIE ][, string $sTargetFileName = '' ]) : void
Parameters
- $iStreamType : int = self::STREAM_TYPE_PRINT_AND_DIE
-
The target stream type to stream the content.
- $sTargetFileName : string = ''
-
The target file name of the stream file.
Tags
Return values
void —writeStream()
Writes the given content to the file stream API object.
public
writeStream(string $sContent[, int|null $iLength = null ]) : int|false
Parameters
- $sContent : string
-
The content, which should be written to the file.
- $iLength : int|null = null
-
If the length argument is given, writing will stop after length bytes have been written or the end of string is reached, whichever comes first.
