Class JStream

Description

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 30)

JObject
   |
   --JStream
Variable Summary
 integer $chunksize
 resource $context
 integer $dirmode
 array $fh
 integer $filemode
 string $filename
 integer $filesize
 array $filters
 string $openmode
 string $readprefix
 string $writeprefix
Method Summary
 JStream __construct ([string $writeprefix = ''], [string $readprefix = ''], [array $context = array()])
 void __destruct ()
 void addContextEntry (string $wrapper, string $name, string $value)
 mixed appendFilter (string $filtername, [integer $read_write = STREAM_FILTER_READ], [array $params = array()])
 boolean chmod ([string $filename = ''], [mixed $mode = 0])
 boolean close ()
 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])
 void deleteContextEntry (string $wrapper, string $name)
 boolean eof ()
 mixed filesize ()
 File getFileHandle ()
 mixed gets ([integer $length = 0])
 array get_meta_data ()
 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 read ([integer $length = 0])
 boolean removeFilter (resource &$resource, [boolean $byindex = false])
 boolean seek (integer $offset, [integer $whence = SEEK_SET])
 void setContextOptions (array $context)
 mixed tell ()
 mixed upload (string $src, string $dest, [resource $context = null], [boolean $use_prefix = true], [boolean $relative = false])
 boolean write (string &$string, [integer $length = 0], [integer $chunk = 0])
 boolean writeFile (string $filename, string &$buffer)
 mixed _buildContext ()
 string _getFilename (string $filename, string $mode, boolean $use_prefix, boolean $relative)
Variables
integer $chunksize = 8192 (line 54)

Default Chunk Size

  • since: 11.1
  • access: protected
resource $context = null (line 119)

Context to use when opening the connection

  • since: 12.1
  • access: protected
array $contextOptions (line 127)

Context options; used to rebuild the context

  • since: 12.1
  • access: protected
integer $dirmode = 0755 (line 46)

Directory Mode

  • since: 11.1
  • access: protected
array $fh (line 103)

File Handle

  • since: 12.1
  • access: protected
integer $filemode = 0644 (line 38)

File Mode

  • since: 11.1
  • access: protected
string $filename (line 62)

Filename

  • since: 11.1
  • access: protected
integer $filesize (line 111)

File size

  • since: 12.1
  • access: protected
array $filters = array() (line 95)

Filters applied to the current stream

  • since: 11.1
  • access: protected
string $openmode (line 135)

The mode under which the file was opened

  • since: 12.1
  • access: protected
string $processingmethod = 'f' (line 87)

Read Processing method

  • var: gz, bz, f If a scheme is detected, fopen will be defaulted To use compression with a network stream use a filter
  • since: 11.1
  • access: protected
string $readprefix (line 78)

Prefix of the connection for reading

  • since: 11.1
  • access: protected
string $writeprefix (line 70)

Prefix of the connection for writing

  • since: 11.1
  • access: protected

Inherited Variables

Inherited from JObject

JObject::$_errors
Methods
Constructor __construct (line 146)

Constructor

  • since: 11.1
  • access: public
JStream __construct ([string $writeprefix = ''], [string $readprefix = ''], [array $context = array()])
  • 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).

Redefinition of:
JObject::__construct()
Class constructor, overridden in descendant classes.
Destructor __destruct (line 159)

Destructor

  • since: 11.1
  • access: public
void __destruct ()
addContextEntry (line 964)

Adds a particular options to the context

void addContextEntry (string $wrapper, string $name, string $value)
  • string $wrapper: The wrapper to use
  • string $name: The option to set
  • string $value: The value of the option
appendFilter (line 1051)

Stream filters Append a filter to the chain

mixed appendFilter (string $filtername, [integer $read_write = STREAM_FILTER_READ], [array $params = array()])
  • 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.
applyContextToStream (line 1014)

Applies the current context to the stream

Use this to change the values of the context after you've opened a stream

  • since: 11.1
  • access: public
mixed applyContextToStream ()
chmod (line 834)

Chmod wrapper

  • since: 11.1
  • access: public
boolean chmod ([string $filename = ''], [mixed $mode = 0])
  • string $filename: File name.
  • mixed $mode: Mode to use.
close (line 305)

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

  • since: 11.1
  • access: public
boolean close ()
copy (line 1173)

Copy a file from src to dest

  • since: 11.1
  • access: public
mixed copy (string $src, string $dest, [resource $context = null], [boolean $use_prefix = true], [boolean $relative = false])
  • 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 (line 1282)

Delete a file

  • since: 11.1
  • access: public
mixed delete (string $filename, [resource $context = null], [boolean $use_prefix = true], [boolean $relative = false])
  • 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.
deleteContextEntry (line 981)

Deletes a particular setting from a context

void deleteContextEntry (string $wrapper, string $name)
  • string $wrapper: The wrapper to use
  • string $name: The option to unset
eof (line 368)

Work out if we're at the end of the file for a stream

  • since: 11.1
  • access: public
boolean eof ()
filesize (line 414)

Retrieve the file size of the path

  • since: 11.1
  • access: public
mixed filesize ()
getFileHandle (line 1421)

Return the internal file handle

  • return: handler
  • since: 11.1
  • access: public
File getFileHandle ()
gets (line 485)

Get a line from the stream source.

  • since: 11.1
  • access: public
mixed gets ([integer $length = 0])
  • integer $length: The number of bytes (optional) to read.
get_meta_data (line 900)

Get the stream metadata

array get_meta_data ()
move (line 1231)

Moves a file

  • since: 11.1
  • access: public
mixed move (string $src, string $dest, [resource $context = null], [boolean $use_prefix = true], [boolean $relative = false])
  • 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.
open (line 186)

Generic File Operations

Open a stream with some lazy loading smarts

  • since: 11.1
  • access: public
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])
  • 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
prependFilter (line 1092)

Prepend a filter to the chain

mixed prependFilter (string $filtername, [integer $read_write = STREAM_FILTER_READ], [array $params = array()])
  • 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 (line 542)

Read a file

Handles user space streams appropriately otherwise any read will return 8192

mixed read ([integer $length = 0])
  • integer $length: Length of data to read
removeFilter (line 1133)

Remove a filter, either by resource (handed out from the append or prepend function) or via getting the filter list)

  • return: Result of operation
  • since: 11.1
  • access: public
boolean removeFilter (resource &$resource, [boolean $byindex = false])
  • resource &$resource: The resource.
  • boolean $byindex: The index of the filter.
seek (line 645)

Seek the file

Note: the return value is different to that of fseek

boolean seek (integer $offset, [integer $whence = SEEK_SET])
  • integer $offset: Offset to use when seeking.
  • integer $whence: Seek mode to use.
setContextOptions (line 945)

Updates the context to the array

Format is the same as the options for stream_context_create

void setContextOptions (array $context)
  • array $context: Options to create the context with
tell (line 698)

Returns the current position of the file read/write pointer.

  • since: 11.1
  • access: public
mixed tell ()
upload (line 1331)

Upload a file

  • since: 11.1
  • access: public
mixed upload (string $src, string $dest, [resource $context = null], [boolean $use_prefix = true], [boolean $relative = false])
  • 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.
write (line 758)

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

boolean write (string &$string, [integer $length = 0], [integer $chunk = 0])
  • string &$string: Reference to the string to write.
  • integer $length: Length of the string to write.
  • integer $chunk: Size of chunks to write in.
writeFile (line 1356)

Writes a chunk of data to a file.

  • since: 11.1
  • access: public
boolean writeFile (string $filename, string &$buffer)
  • string $filename: The file name.
  • string &$buffer: The data to write to the file.
_buildContext (line 920)

Stream contexts Builds the context from the array

  • since: 11.1
  • access: public
mixed _buildContext ()
_getFilename (line 1382)

Determine the appropriate 'filename' of a file

  • since: 11.1
  • access: public
string _getFilename (string $filename, string $mode, boolean $use_prefix, boolean $relative)
  • 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()

Documentation generated on Tue, 19 Nov 2013 15:14:28 +0100 by phpDocumentor 1.4.3