Constructor
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
void
__destruct
()
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
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.
Applies the current context to the stream
Use this to change the values of the context after you've opened a stream
mixed
applyContextToStream
()
Chmod wrapper
boolean
chmod
([string $filename = ''], [mixed $mode = 0])
-
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
boolean
close
()
Copy a file from src to dest
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 a file
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.
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
Work out if we're at the end of the file for a stream
boolean
eof
()
Retrieve the file size of the path
mixed
filesize
()
Return the internal file handle
File
getFileHandle
()
Get a line from the stream source.
mixed
gets
([integer $length = 0])
-
integer
$length: The number of bytes (optional) to read.
Get the stream metadata
array
get_meta_data
()
Moves a file
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.
Generic File Operations
Open a stream with some lazy loading smarts
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
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 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
Remove a filter, either by resource (handed out from the append or prepend function) or via getting the filter list)
boolean
removeFilter
(resource &$resource, [boolean $byindex = false])
-
resource
&$resource: The resource.
-
boolean
$byindex: The index of the filter.
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.
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
Returns the current position of the file read/write pointer.
mixed
tell
()
Upload a file
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.
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.
Writes a chunk of data to a file.
boolean
writeFile
(string $filename, string &$buffer)
-
string
$filename: The file name.
-
string
&$buffer: The data to write to the file.
Stream contexts Builds the context from the array
mixed
_buildContext
()
Determine the appropriate 'filename' of a file
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()