public
|
#
__construct( string $writeprefix = '', string $readprefix = '', array $context = array() )
Constructor
Parameters
- $writeprefix
string - $writeprefix Prefix of the stream (optional). Unlike the JPATH_*, this has a
final path separator!
- $readprefix
string - $readprefix The read prefix (optional).
- $context
array - $context The context options (optional).
Since
11.1
Overrides
|
public
|
|
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 )
Generic File Operations
Open a stream with some lazy loading smarts
Parameters
- $filename
string - $filename Filename
- $mode
string - $mode Mode string to use
- $use_include_path
boolean - $use_include_path Use the PHP include path
- $context
resource - $context Context to use when opening
- $use_prefix
boolean - $use_prefix Use a prefix to open the file
- $relative
boolean - $relative Filename is a relative path (if false, strips JPATH_ROOT to make it
relative)
- $detectprocessingmode
boolean - $detectprocessingmode Detect the processing method for the file and use the
appropriate function to handle output automatically
Returns
boolean
Since
11.1
|
public
boolean
|
#
close( )
Attempt to close a file handle
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
Returns
boolean
Since
11.1
|
public
boolean
|
#
eof( )
Work out if we're at the end of the file for a stream
Work out if we're at the end of the file for a stream
Returns
boolean
Since
11.1
|
public
mixed
|
#
filesize( )
Retrieve the file size of the path
Retrieve the file size of the path
Returns
mixed
Since
11.1
|
public
mixed
|
#
gets( integer $length = 0 )
Get a line from the stream source.
Get a line from the stream source.
Parameters
- $length
integer - $length The number of bytes (optional) to read.
Returns
mixed
Since
11.1
|
public
mixed
|
#
read( integer $length = 0 )
Read a file
Handles user space streams appropriately otherwise any read will return
8192
Parameters
- $length
integer - $length Length of data to read
Returns
mixed
Since
11.1
Link
|
public
boolean
|
#
seek( integer $offset, integer $whence = SEEK_SET )
Seek the file
Note: the return value is different to that of fseek
Parameters
- $offset
integer - $offset Offset to use when seeking.
- $whence
integer - $whence Seek mode to use.
Returns
boolean - True on success, false on failure
Since
11.1
Link
|
public
mixed
|
#
tell( )
Returns the current position of the file read/write pointer.
Returns the current position of the file read/write pointer.
Returns
mixed
Since
11.1
|
public
boolean
|
#
write( string & $string, integer $length = 0, integer $chunk = 0 )
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
Parameters
- $string
string - &$string Reference to the string to write.
- $length
integer - $length Length of the string to write.
- $chunk
integer - $chunk Size of chunks to write in.
Returns
boolean
Since
11.1
Link
|
public
boolean
|
#
chmod( string $filename = '', mixed $mode = 0 )
Chmod wrapper
Parameters
- $filename
string - $filename File name.
- $mode
mixed - $mode Mode to use.
Returns
boolean
Since
11.1
|
public
array
|
#
get_meta_data( )
Get the stream metadata
Returns
array - header/metadata
Since
11.1
Link
|
public
mixed
|
#
_buildContext( )
Stream contexts Builds the context from the array
Stream contexts Builds the context from the array
Returns
mixed
Since
11.1
|
public
|
#
setContextOptions( array $context )
Updates the context to the array
Updates the context to the array
Format is the same as the options for stream_context_create
Parameters
- $context
array - $context Options to create the context with
Since
11.1
Link
|
public
|
#
addContextEntry( string $wrapper, string $name, string $value )
Adds a particular options to the context
Adds a particular options to the context
Parameters
- $wrapper
string - $wrapper The wrapper to use
- $name
string - $name The option to set
- $value
string - $value The value of the option
Since
11.1
Link
|
public
|
#
deleteContextEntry( string $wrapper, string $name )
Deletes a particular setting from a context
Deletes a particular setting from a context
Parameters
- $wrapper
string - $wrapper The wrapper to use
- $name
string - $name The option to unset
Since
11.1
Link
|
public
mixed
|
#
applyContextToStream( )
Applies the current context to the stream
Applies the current context to the stream
Use this to change the values of the context after you've opened a stream
Returns
mixed
Since
11.1
|
public
mixed
|
#
appendFilter( string $filtername, integer $read_write = STREAM_FILTER_READ, array $params = array() )
Stream filters Append a filter to the chain
Stream filters Append a filter to the chain
Parameters
- $filtername
string - $filtername The key name of the filter.
- $read_write
integer - $read_write Optional. Defaults to STREAM_FILTER_READ.
- $params
array - $params An array of params for the stream_filter_append call.
Returns
mixed
Since
11.1
Link
|
public
mixed
|
#
prependFilter( string $filtername, integer $read_write = STREAM_FILTER_READ, array $params = array() )
Prepend a filter to the chain
Prepend a filter to the chain
Parameters
- $filtername
string - $filtername The key name of the filter.
- $read_write
integer - $read_write Optional. Defaults to STREAM_FILTER_READ.
- $params
array - $params An array of params for the stream_filter_prepend call.
Returns
mixed
Since
11.1
Link
|
public
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)
Remove a filter, either by resource (handed out from the append or prepend
function) or via getting the filter list)
Parameters
- $resource
resource - &$resource The resource.
- $byindex
boolean - $byindex The index of the filter.
Returns
boolean - Result of operation
Since
11.1
|
public
mixed
|
#
copy( string $src, string $dest, resource $context = null, boolean $use_prefix = true, boolean $relative = false )
Copy a file from src to dest
Copy a file from src to dest
Parameters
- $src
string - $src The file path to copy from.
- $dest
string - $dest The file path to copy to.
- $context
resource - $context A valid context resource (optional) created with stream_context_create.
- $use_prefix
boolean - $use_prefix Controls the use of a prefix (optional).
- $relative
boolean - $relative Determines if the filename given is relative. Relative paths do not
have JPATH_ROOT stripped.
Returns
mixed
Since
11.1
|
public
mixed
|
#
move( string $src, string $dest, resource $context = null, boolean $use_prefix = true, boolean $relative = false )
Moves a file
Parameters
- $src
string - $src The file path to move from.
- $dest
string - $dest The file path to move to.
- $context
resource - $context A valid context resource (optional) created with stream_context_create.
- $use_prefix
boolean - $use_prefix Controls the use of a prefix (optional).
- $relative
boolean - $relative Determines if the filename given is relative. Relative paths do not
have JPATH_ROOT stripped.
Returns
mixed
Since
11.1
|
public
mixed
|
#
delete( string $filename, resource $context = null, boolean $use_prefix = true, boolean $relative = false )
Delete a file
Parameters
- $filename
string - $filename The file path to delete.
- $context
resource - $context A valid context resource (optional) created with stream_context_create.
- $use_prefix
boolean - $use_prefix Controls the use of a prefix (optional).
- $relative
boolean - $relative Determines if the filename given is relative. Relative paths do not
have JPATH_ROOT stripped.
Returns
mixed
Since
11.1
|
public
mixed
|
#
upload( string $src, string $dest, resource $context = null, boolean $use_prefix = true, boolean $relative = false )
Upload a file
Parameters
- $src
string - $src The file path to copy from (usually a temp folder).
- $dest
string - $dest The file path to copy to.
- $context
resource - $context A valid context resource (optional) created with stream_context_create.
- $use_prefix
boolean - $use_prefix Controls the use of a prefix (optional).
- $relative
boolean - $relative Determines if the filename given is relative. Relative paths do not
have JPATH_ROOT stripped.
Returns
mixed
Since
11.1
|
public
boolean
|
#
writeFile( string $filename, string & $buffer )
Writes a chunk of data to a file.
Writes a chunk of data to a file.
Parameters
- $filename
string - $filename The file name.
- $buffer
string - &$buffer The data to write to the file.
Returns
boolean
Since
11.1
|
public
string
|
#
_getFilename( string $filename, string $mode, boolean $use_prefix, boolean $relative )
Determine the appropriate 'filename' of a file
Determine the appropriate 'filename' of a file
Parameters
- $filename
string - $filename Original filename of the file
- $mode
string - $mode Mode string to retrieve the filename
- $use_prefix
boolean - $use_prefix Controls the use of a prefix
- $relative
boolean - $relative Determines if the filename given is relative. Relative paths do not
have JPATH_ROOT stripped.
Returns
string
Since
11.1
|
public
File
|
#
getFileHandle( )
Return the internal file handle
Return the internal file handle
Returns
File - handler
Since
11.1
|