[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Filesystem/ -> Stream.php (summary)

Joomla! Content Management System

Copyright: (C) 2008 Open Source Matters, Inc.
License: GNU General Public License version 2 or later; see LICENSE.txt
File Size: 1303 lines (37 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Stream:: (28 methods):
  __construct()
  __destruct()
  open()
  close()
  eof()
  filesize()
  gets()
  read()
  seek()
  tell()
  write()
  chmod()
  get_meta_data()
  _buildContext()
  setContextOptions()
  addContextEntry()
  deleteContextEntry()
  applyContextToStream()
  appendFilter()
  prependFilter()
  removeFilter()
  copy()
  move()
  delete()
  upload()
  writeFile()
  _getFilename()
  getFileHandle()


Class: Stream  - X-Ref

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.

__construct($writeprefix = '', $readprefix = '', $context = array()   X-Ref
Constructor

param: string  $writeprefix  Prefix of the stream (optional). Unlike the JPATH_*, this has a final path separator!
param: string  $readprefix   The read prefix (optional).
param: array   $context      The context options (optional).

__destruct()   X-Ref
Destructor


open($filename,$mode = 'r',$useIncludePath = false,$context = null,$usePrefix = false,$relative = false,$detectProcessingMode = false)   X-Ref
Generic File Operations

Open a stream with some lazy loading smarts

param: string    $filename              Filename
param: string    $mode                  Mode string to use
param: boolean   $useIncludePath        Use the PHP include path
param: resource  $context               Context to use when opening
param: boolean   $usePrefix             Use a prefix to open the file
param: boolean   $relative              Filename is a relative path (if false, strips JPATH_ROOT to make it relative)
param: boolean   $detectProcessingMode  Detect the processing method for the file and use the appropriate function
return: boolean

close()   X-Ref
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

return: boolean

eof()   X-Ref
Work out if we're at the end of the file for a stream

return: boolean

filesize()   X-Ref
Retrieve the file size of the path

return: mixed

gets($length = 0)   X-Ref
Get a line from the stream source.

param: integer  $length  The number of bytes (optional) to read.
return: mixed

read($length = 0)   X-Ref
Read a file

Handles user space streams appropriately otherwise any read will return 8192

param: integer  $length  Length of data to read
return: mixed

seek($offset, $whence = SEEK_SET)   X-Ref
Seek the file

Note: the return value is different to that of fseek

param: integer  $offset  Offset to use when seeking.
param: integer  $whence  Seek mode to use.
return: boolean  True on success, false on failure

tell()   X-Ref
Returns the current position of the file read/write pointer.

return: mixed

write(&$string, $length = 0, $chunk = 0)   X-Ref
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

param: string   $string  Reference to the string to write.
param: integer  $length  Length of the string to write.
param: integer  $chunk   Size of chunks to write in.
return: boolean

chmod($filename = '', $mode = 0)   X-Ref
Chmod wrapper

param: string  $filename  File name.
param: mixed   $mode      Mode to use.
return: boolean

get_meta_data()   X-Ref
Get the stream metadata

return: array|boolean  header/metadata

_buildContext()   X-Ref
Stream contexts
Builds the context from the array

return: mixed

setContextOptions($context)   X-Ref
Updates the context to the array

Format is the same as the options for stream_context_create

param: array  $context  Options to create the context with
return: void

addContextEntry($wrapper, $name, $value)   X-Ref
Adds a particular options to the context

param: string  $wrapper  The wrapper to use
param: string  $name     The option to set
param: string  $value    The value of the option
return: void

deleteContextEntry($wrapper, $name)   X-Ref
Deletes a particular setting from a context

param: string  $wrapper  The wrapper to use
param: string  $name     The option to unset
return: void

applyContextToStream()   X-Ref
Applies the current context to the stream

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

return: mixed

appendFilter($filterName, $readWrite = STREAM_FILTER_READ, $params = array()   X-Ref
Stream filters
Append a filter to the chain

param: string   $filterName  The key name of the filter.
param: integer  $readWrite   Optional. Defaults to STREAM_FILTER_READ.
param: array    $params      An array of params for the stream_filter_append call.
return: mixed

prependFilter($filterName, $readWrite = STREAM_FILTER_READ, $params = array()   X-Ref
Prepend a filter to the chain

param: string   $filterName  The key name of the filter.
param: integer  $readWrite   Optional. Defaults to STREAM_FILTER_READ.
param: array    $params      An array of params for the stream_filter_prepend call.
return: mixed

removeFilter(&$resource, $byindex = false)   X-Ref
Remove a filter, either by resource (handed out from the append or prepend function)
or via getting the filter list)

param: resource  $resource  The resource.
param: boolean   $byindex   The index of the filter.
return: boolean   Result of operation

copy($src, $dest, $context = null, $usePrefix = true, $relative = false)   X-Ref
Copy a file from src to dest

param: string    $src        The file path to copy from.
param: string    $dest       The file path to copy to.
param: resource  $context    A valid context resource (optional) created with stream_context_create.
param: boolean   $usePrefix  Controls the use of a prefix (optional).
param: boolean   $relative   Determines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped.
return: mixed

move($src, $dest, $context = null, $usePrefix = true, $relative = false)   X-Ref
Moves a file

param: string    $src        The file path to move from.
param: string    $dest       The file path to move to.
param: resource  $context    A valid context resource (optional) created with stream_context_create.
param: boolean   $usePrefix  Controls the use of a prefix (optional).
param: boolean   $relative   Determines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped.
return: mixed

delete($filename, $context = null, $usePrefix = true, $relative = false)   X-Ref
Delete a file

param: string    $filename   The file path to delete.
param: resource  $context    A valid context resource (optional) created with stream_context_create.
param: boolean   $usePrefix  Controls the use of a prefix (optional).
param: boolean   $relative   Determines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped.
return: mixed

upload($src, $dest, $context = null, $usePrefix = true, $relative = false)   X-Ref
Upload a file

param: string    $src        The file path to copy from (usually a temp folder).
param: string    $dest       The file path to copy to.
param: resource  $context    A valid context resource (optional) created with stream_context_create.
param: boolean   $usePrefix  Controls the use of a prefix (optional).
param: boolean   $relative   Determines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped.
return: mixed

writeFile($filename, &$buffer)   X-Ref
Writes a chunk of data to a file.

param: string  $filename  The file name.
param: string  $buffer    The data to write to the file.
return: boolean

_getFilename($filename, $mode, $usePrefix, $relative)   X-Ref
Determine the appropriate 'filename' of a file

param: string   $filename   Original filename of the file
param: string   $mode       Mode string to retrieve the filename
param: boolean  $usePrefix  Controls the use of a prefix
param: boolean  $relative   Determines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped.
return: string

getFileHandle()   X-Ref
Return the internal file handle

return: resource  File handler



Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer