JStream
Joomla! Stream Interface
The Joomla! stream interface is designed to handle files as streams where as the legacy JFile static class treated files in a rather atomic manner.
Located in /libraries/joomla/filesystem/stream.php (line 31)
JObject (Subpackage Object)
![]()
JStream (Subpackage FileSystem--)
JStream
__construct
([string $writeprefix = ''], [string $readprefix = ''], [array $context = array()])
mixed
appendFilter
(string $filtername, [integer $read_write = STREAM_FILTER_READ], [array $params = array()])
mixed
copy
(string $src, string $dest, [resource $context = null], [boolean $use_prefix = true], [boolean $relative = false])
mixed
delete
(string $filename, [resource $context = null], [boolean $use_prefix = true], [boolean $relative = false])
mixed
move
(string $src, string $dest, [resource $context = null], [boolean $use_prefix = true], [boolean $relative = false])
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])
mixed
prependFilter
(string $filtername, [integer $read_write = STREAM_FILTER_READ], [array $params = array()])
mixed
upload
(string $src, string $dest, [resource $context = null], [boolean $use_prefix = true], [boolean $relative = false])
integer
$chunksize
= 8192 (line 53)
Default Chunk Size
$context
= null (line 112)
Context to use when opening the connection
$contextOptions
(line 119)
Context options; used to rebuild the context
integer
$dirmode
= 0755 (line 46)
Directory Mode
array
$fh
(line 98)
File Handle
integer
$filemode
= 0644 (line 39)
File Mode
string
$filename
(line 60)
Filename
integer
$filesize
(line 105)
File size
array
$filters
= array() (line 91)
Filters applied to the current stream
$openmode
(line 126)
The mode under which the file was opened
string
$processingmethod
= 'f' (line 84)
Read Processing method
string
$readprefix
(line 74)
Prefix of the connection for reading
string
$writeprefix
(line 67)
Prefix of the connection for writing
Inherited Variables
Inherited from JObject
JObject::$_errors
Constructor
- string $writeprefix: Prefix of the stream (optional). Unlike the JPATH_*, this has a final path separator!
- string $readprefix: The read prefix (optional).
- array $context: The context options (optional).
- JObject::__construct()
- Class constructor, overridden in descendant classes.
Adds a particular options to the context
- string $wrapper: The wrapper to use
- string $name: The option to set
- string $value: The value of the option
Stream filters Append a filter to the chain
- string $filtername: The key name of the filter.
- integer $read_write: Optional. Defaults to STREAM_FILTER_READ.
- array $params: An array of params for the stream_filter_append call.
Applies the current context to the stream
Use this to change the values of the context after you've opened a stream
Chmod wrapper
- string $filename: File name.
- mixed $mode: Mode to use.
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
Copy a file from src to dest
- string $src: The file path to copy from.
- string $dest: The file path to copy to.
- resource $context: A valid context resource (optional) created with stream_context_create.
- boolean $use_prefix: Controls the use of a prefix (optional).
- boolean $relative: Determines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped.
Delete a file
- string $filename: The file path to delete.
- resource $context: A valid context resource (optional) created with stream_context_create.
- boolean $use_prefix: Controls the use of a prefix (optional).
- boolean $relative: Determines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped.
Deletes a particular setting from a context
- string $wrapper: The wrapper to use
- string $name: The option to unset
Get a line from the stream source.
- integer $length: The number of bytes (optional) to read.
Moves a file
- string $src: The file path to move from.
- string $dest: The file path to move to.
- resource $context: A valid context resource (optional) created with stream_context_create.
- boolean $use_prefix: Controls the use of a prefix (optional).
- boolean $relative: Determines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped.
Generic File Operations
Open a stream with some lazy loading smarts
- string $filename: Filename
- string $mode: Mode string to use
- boolean $use_include_path: Use the PHP include path
- resource $context: Context to use when opening
- boolean $use_prefix: Use a prefix to open the file
- boolean $relative: Filename is a relative path (if false, strips JPATH_ROOT to make it relative)
- boolean $detectprocessingmode: Detect the processing method for the file and use the appropriate function to handle output automatically
Prepend a filter to the chain
- string $filtername: The key name of the filter.
- integer $read_write: Optional. Defaults to STREAM_FILTER_READ.
- array $params: An array of params for the stream_filter_prepend call.
Read a file
Handles user space streams appropriately otherwise any read will return 8192
- integer $length: Length of data to read
Remove a filter, either by resource (handed out from the append or prepend function) or via getting the filter list)
- resource &$resource: The resource.
- boolean $byindex: The index of the filter.
Seek the file
Note: the return value is different to that of fseek
- integer $offset: Offset to use when seeking.
- integer $whence: Seek mode to use.
Updates the context to the array
Format is the same as the options for stream_context_create
- array $context: Options to create the context with
Upload a file
- string $src: The file path to copy from (usually a temp folder).
- string $dest: The file path to copy to.
- resource $context: A valid context resource (optional) created with stream_context_create.
- boolean $use_prefix: Controls the use of a prefix (optional).
- boolean $relative: Determines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped.
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
- string &$string: Reference to the string to write.
- integer $length: Length of the string to write.
- integer $chunk: Size of chunks to write in.
Writes a chunk of data to a file.
- string $filename: The file name.
- string &$buffer: The data to write to the file.
Determine the appropriate 'filename' of a file
- string $filename: Original filename of the file
- string $mode: Mode string to retrieve the filename
- boolean $use_prefix: Controls the use of a prefix
- boolean $relative: Determines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped.
Inherited Methods
Inherited From JObject
JObject::__construct()
JObject::def()
JObject::get()
JObject::getError()
JObject::getErrors()
JObject::getProperties()
JObject::set()
JObject::setError()
JObject::setProperties()
JObject::__toString()
