Stream
class Stream extends CMSObject
Joomla! Stream Interface
The Joomla! stream interface is designed to handle files as streams where as the legacy File static class treated files in a rather atomic manner.
Methods
Constructor
Sets a default value if not already assigned
Returns a property of the object or the default value if the property is not set.
Returns an associative array of object properties.
Get the most recent error message.
Modifies a property of the object, creating it if it does not already exist.
Set the object properties based on a named array/hash.
Destructor
Generic File Operations
Attempt to close a file handle
Work out if we're at the end of the file for a stream
Retrieve the file size of the path
Get a line from the stream source.
Read a file
Seek the file
Returns the current position of the file read/write pointer.
File write
Chmod wrapper
Get the stream metadata
Stream contexts Builds the context from the array
Updates the context to the array
Adds a particular options to the context
Deletes a particular setting from a context
Applies the current context to the stream
Stream filters Append a filter to the chain
Prepend a filter to the chain
Remove a filter, either by resource (handed out from the append or prepend function) or via getting the filter list)
Copy a file from src to dest
Moves a file
Delete a file
Upload a file
Writes a chunk of data to a file.
Determine the appropriate 'filename' of a file
Return the internal file handle
Details
__construct(
string $writeprefix = '',
string $readprefix = '',
array $context = array())
Constructor
mixed
get(
string $property,
mixed $default = null)
Returns a property of the object or the default value if the property is not set.
mixed
set(
string $property,
mixed $value = null)
Modifies a property of the object, creating it if it does not already exist.
boolean
open(
string $filename,
string $mode = 'r',
boolean $use_include_path = false,
resource $context = null,
boolean $use_prefix = false,
boolean $relative = false,
boolean $detectprocessingmode = false)
Generic File Operations
Open a stream with some lazy loading smarts
boolean
close()
Attempt to close a file handle
Will return false if it failed and true on success If the file is not open the system will return true, this function destroys the file handle as well
mixed
read(
integer $length)
Read a file
Handles user space streams appropriately otherwise any read will return 8192
boolean
seek(
integer $offset,
integer $whence = SEEK_SET)
Seek the file
Note: the return value is different to that of fseek
boolean
write(
string $string,
integer $length,
integer $chunk)
File write
Whilst this function accepts a reference, the underlying fwrite will do a copy! This will roughly double the memory allocation for any write you do. Specifying chunked will get around this by only writing in specific chunk sizes. This defaults to 8192 which is a sane number to use most of the time (change the default with JStream::set('chunksize', newsize);) Note: This doesn't support gzip/bzip2 writing like reading does
void
setContextOptions(
array $context)
Updates the context to the array
Format is the same as the options for streamcontextcreate
void
addContextEntry(
string $wrapper,
string $name,
string $value)
Adds a particular options to the context
mixed
applyContextToStream()
Applies the current context to the stream
Use this to change the values of the context after you've opened a stream
mixed
appendFilter(
string $filtername,
integer $read_write = STREAM_FILTER_READ,
array $params = array())
Stream filters Append a filter to the chain
mixed
prependFilter(
string $filtername,
integer $read_write = STREAM_FILTER_READ,
array $params = array())
Prepend a filter to the chain
boolean
removeFilter(
resource $resource,
boolean $byindex = false)
Remove a filter, either by resource (handed out from the append or prepend function) or via getting the filter list)
mixed
copy(
string $src,
string $dest,
resource $context = null,
boolean $use_prefix = true,
boolean $relative = false)
Copy a file from src to dest
mixed
move(
string $src,
string $dest,
resource $context = null,
boolean $use_prefix = true,
boolean $relative = false)
Moves a file
mixed
delete(
string $filename,
resource $context = null,
boolean $use_prefix = true,
boolean $relative = false)
Delete a file
mixed
upload(
string $src,
string $dest,
resource $context = null,
boolean $use_prefix = true,
boolean $relative = false)
Upload a file