Back to Joomla project (class list)

Class Stream - list of methods

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.

Extends

Package: Joomla\CMS\Filesystem
Copyright: (C) 2008 Open Source Matters, Inc.
License: GNU General Public License version 2 or later; see LICENSE.txt
Located at: Joomla/Filesystem/Stream.php
Project: Joomla

Method Summary

public
(mixed $writeprefix = '', mixed $readprefix = '', mixed $context = array())

Constructor
Parameters
  • 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).
Since
  • 1.7.0
Show source code of this method: __construct Source Code

public
()

Destructor
Since
  • 1.7.0
Show source code of this method: __destruct Source Code

public bool
(mixed $filename, mixed $mode = 'r', mixed $useIncludePath = false, mixed $context = null, mixed $usePrefix = false, mixed $relative = false, mixed $detectProcessingMode = false)

Generic File Operations
Parameters
  • string $filename Filename
  • string $mode Mode string to use
  • bool $useIncludePath Use the PHP include path
  • resource $context Context to use when opening
  • bool $usePrefix Use a prefix to open the file
  • bool $relative Filename is a relative path (if false, strips JPATH_ROOT to make it relative)
  • bool $detectProcessingMode Detect the processing method for the file and use the appropriate function to handle output automatically
Returns
  • bool
Since
  • 1.7.0
Show source code of this method: open Source Code

public bool
()

Attempt to close a file handle
Returns
  • bool
Since
  • 1.7.0
Show source code of this method: close Source Code

public bool
()

Work out if we're at the end of the file for a stream
Returns
  • bool
Since
  • 1.7.0
Show source code of this method: eof Source Code

public mixed
()

Retrieve the file size of the path
Returns
  • mixed
Since
  • 1.7.0
Show source code of this method: filesize Source Code

public mixed
(mixed $length = 0)

Get a line from the stream source.
Parameters
  • int $length The number of bytes (optional) to read.
Returns
  • mixed
Since
  • 1.7.0
Show source code of this method: gets Source Code

public mixed
(mixed $length = 0)

Read a file
Parameters
  • int $length Length of data to read
Returns
  • mixed
Since
  • 1.7.0
-
  • https://www.php.net/manual/en/function.fread.php
Show source code of this method: read Source Code

public bool
(mixed $offset, mixed $whence = SEEK_SET)

Seek the file
Parameters
  • int $offset Offset to use when seeking.
  • int $whence Seek mode to use.
Returns
  • bool True on success, false on failure
Since
  • 1.7.0
-
  • https://www.php.net/manual/en/function.fseek.php
Show source code of this method: seek Source Code

public mixed
()

Returns the current position of the file read/write pointer.
Returns
  • mixed
Since
  • 1.7.0
Show source code of this method: tell Source Code

public bool
(mixed &$string, mixed $length = 0, mixed $chunk = 0)

File write
Parameters
  • string $string Reference to the string to write.
  • int $length Length of the string to write.
  • int $chunk Size of chunks to write in.
Returns
  • bool
Since
  • 1.7.0
-
  • https://www.php.net/manual/en/function.fwrite.php
Show source code of this method: write Source Code

public bool
(mixed $filename = '', mixed $mode = 0)

Chmod wrapper
Parameters
  • string $filename File name.
  • mixed $mode Mode to use.
Returns
  • bool
Since
  • 1.7.0
Show source code of this method: chmod Source Code

public array|bool
()

Get the stream metadata
Returns
  • array|bool header/metadata
Since
  • 1.7.0
-
  • https://www.php.net/manual/en/function.stream-get-meta-data.php
Show source code of this method: get_meta_data Source Code

public mixed
()

Stream contexts Builds the context from the array
Returns
  • mixed
Since
  • 1.7.0
Show source code of this method: _buildContext Source Code

public void
(mixed $context)

Updates the context to the array
Parameters
  • array $context Options to create the context with
Returns
  • void
Since
  • 1.7.0
-
  • https://www.php.net/stream_context_create
Show source code of this method: setContextOptions Source Code

public void
(mixed $wrapper, mixed $name, mixed $value)

Adds a particular options to the context
Parameters
  • string $wrapper The wrapper to use
  • string $name The option to set
  • string $value The value of the option
Returns
  • void
Since
  • 1.7.0
-
  • https://www.php.net/stream_context_create Stream Context Creation
  • https://www.php.net/manual/en/context.php Context Options for various streams
Show source code of this method: addContextEntry Source Code

public void
(mixed $wrapper, mixed $name)

Deletes a particular setting from a context
Parameters
  • string $wrapper The wrapper to use
  • string $name The option to unset
Returns
  • void
Since
  • 1.7.0
-
  • https://www.php.net/stream_context_create
Show source code of this method: deleteContextEntry Source Code

public mixed
()

Applies the current context to the stream
Returns
  • mixed
Since
  • 1.7.0
Show source code of this method: applyContextToStream Source Code

public mixed
(mixed $filterName, mixed $readWrite = STREAM_FILTER_READ, mixed $params = array())

Stream filters Append a filter to the chain
Parameters
  • string $filterName The key name of the filter.
  • int $readWrite Optional. Defaults to STREAM_FILTER_READ.
  • array $params An array of params for the stream_filter_append call.
Returns
  • mixed
Since
  • 1.7.0
-
  • https://www.php.net/manual/en/function.stream-filter-append.php
Show source code of this method: appendFilter Source Code

public mixed
(mixed $filterName, mixed $readWrite = STREAM_FILTER_READ, mixed $params = array())

Prepend a filter to the chain
Parameters
  • string $filterName The key name of the filter.
  • int $readWrite Optional. Defaults to STREAM_FILTER_READ.
  • array $params An array of params for the stream_filter_prepend call.
Returns
  • mixed
Since
  • 1.7.0
-
  • https://www.php.net/manual/en/function.stream-filter-prepend.php
Show source code of this method: prependFilter Source Code

public bool
(mixed &$resource, mixed $byindex = false)

Remove a filter, either by resource (handed out from the append or prepend function) or via getting the filter list)
Parameters
  • resource $resource The resource.
  • bool $byindex The index of the filter.
Returns
  • bool Result of operation
Since
  • 1.7.0
Show source code of this method: removeFilter Source Code

public mixed
(mixed $src, mixed $dest, mixed $context = null, mixed $usePrefix = true, mixed $relative = false)

Copy a file from src to dest
Parameters
  • 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.
  • bool $usePrefix Controls the use of a prefix (optional).
  • bool $relative Determines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped.
Returns
  • mixed
Since
  • 1.7.0
Show source code of this method: copy Source Code

public mixed
(mixed $src, mixed $dest, mixed $context = null, mixed $usePrefix = true, mixed $relative = false)

Moves a file
Parameters
  • 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.
  • bool $usePrefix Controls the use of a prefix (optional).
  • bool $relative Determines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped.
Returns
  • mixed
Since
  • 1.7.0
Show source code of this method: move Source Code

public mixed
(mixed $filename, mixed $context = null, mixed $usePrefix = true, mixed $relative = false)

Delete a file
Parameters
  • string $filename The file path to delete.
  • resource $context A valid context resource (optional) created with stream_context_create.
  • bool $usePrefix Controls the use of a prefix (optional).
  • bool $relative Determines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped.
Returns
  • mixed
Since
  • 1.7.0
Show source code of this method: delete Source Code

public mixed
(mixed $src, mixed $dest, mixed $context = null, mixed $usePrefix = true, mixed $relative = false)

Upload a file
Parameters
  • 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.
  • bool $usePrefix Controls the use of a prefix (optional).
  • bool $relative Determines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped.
Returns
  • mixed
Since
  • 1.7.0
Show source code of this method: upload Source Code

public bool
(mixed $filename, mixed &$buffer)

Writes a chunk of data to a file.
Parameters
  • string $filename The file name.
  • string $buffer The data to write to the file.
Returns
  • bool
Since
  • 1.7.0
Show source code of this method: writeFile Source Code

public string
(mixed $filename, mixed $mode, mixed $usePrefix, mixed $relative)

Determine the appropriate 'filename' of a file
Parameters
  • string $filename Original filename of the file
  • string $mode Mode string to retrieve the filename
  • bool $usePrefix Controls the use of a prefix
  • bool $relative Determines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped.
Returns
  • string
Since
  • 1.7.0
Show source code of this method: _getFilename Source Code

public resource
()

Return the internal file handle
Returns
  • resource File handler
Since
  • 1.7.0
Show source code of this method: getFileHandle Source Code

Properties Summary

protected int
$filemode
File Mode
Since
  • 1.7.0
protected int
$dirmode
Directory Mode
Since
  • 1.7.0
protected int
$chunksize
Default Chunk Size
Since
  • 1.7.0
protected string
$filename
Filename
Since
  • 1.7.0
protected string
$writeprefix
Prefix of the connection for writing
Since
  • 1.7.0
protected string
$readprefix
Prefix of the connection for reading
Since
  • 1.7.0
protected string
$processingmethod
Read Processing method
Since
  • 1.7.0
protected array
$filters
Filters applied to the current stream
Since
  • 1.7.0
protected resource
$fh
File Handle
Since
  • 3.0.0
protected int
$filesize
File size
Since
  • 3.0.0
protected resource
$context
Context to use when opening the connection
Since
  • 3.0.0
protected array
$contextOptions
Context options; used to rebuild the context
Since
  • 3.0.0
protected string
$openmode
The mode under which the file was opened
Since
  • 3.0.0

Tags Summary

Since
1.7.0