Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
Référence de la classe JStream
+ Graphe d'héritage de JStream:
+ Graphe de collaboration de JStream:

Liste de tous les membres

Fonctions membres publiques

 __construct ($writeprefix= '', $readprefix= '', $context=array())
 __destruct ()
 open ($filename, $mode= 'r', $use_include_path=false, $context=null, $use_prefix=false, $relative=false, $detectprocessingmode=false)
 close ()
 eof ()
 filesize ()
 gets ($length=0)
 read ($length=0)
 seek ($offset, $whence=SEEK_SET)
 tell ()
 write (&$string, $length=0, $chunk=0)
 chmod ($filename= '', $mode=0)
 get_meta_data ()
 _buildContext ()
 setContextOptions ($context)
 addContextEntry ($wrapper, $name, $value)
 deleteContextEntry ($wrapper, $name)
 applyContextToStream ()
 appendFilter ($filtername, $read_write=STREAM_FILTER_READ, $params=array())
 prependFilter ($filtername, $read_write=STREAM_FILTER_READ, $params=array())
 removeFilter (&$resource, $byindex=false)
 copy ($src, $dest, $context=null, $use_prefix=true, $relative=false)
 move ($src, $dest, $context=null, $use_prefix=true, $relative=false)
 delete ($filename, $context=null, $use_prefix=true, $relative=false)
 upload ($src, $dest, $context=null, $use_prefix=true, $relative=false)
 writeFile ($filename, &$buffer)
 _getFilename ($filename, $mode, $use_prefix, $relative)
 getFileHandle ()
- Fonctions membres publiques inherited from JObject
 __construct ($properties=null)
 __toString ()
 def ($property, $default=null)
 get ($property, $default=null)
 getProperties ($public=true)
 getError ($i=null, $toString=true)
 getErrors ()
 set ($property, $value=null)
 setProperties ($properties)
 setError ($error)

Attributs protégés

 $filemode = 0644
 $dirmode = 0755
 $chunksize = 8192
 $filename
 $writeprefix
 $readprefix
 $processingmethod = 'f'
 $filters = array()
 $fh
 $filesize
 $context = null
 $contextOptions
 $openmode
- Attributs protégés inherited from JObject
 $_errors = array()

Description détaillée

Définition à la ligne 30 du fichier stream.php.


Documentation des constructeurs et destructeur

JStream::__construct (   $writeprefix = '',
  $readprefix = '',
  $context = array() 
)

Constructor

Paramètres:
string$writeprefixPrefix of the stream (optional). Unlike the JPATH_*, this has a final path separator!
string$readprefixThe read prefix (optional).
array$contextThe context options (optional).
Depuis:
11.1

Définition à la ligne 146 du fichier stream.php.

{
$this->writeprefix = $writeprefix;
$this->readprefix = $readprefix;
$this->contextOptions = $context;
$this->_buildContext();
}
JStream::__destruct ( )

Destructor

Depuis:
11.1

Définition à la ligne 159 du fichier stream.php.

{
// Attempt to close on destruction if there is a file handle
if ($this->fh)
{
@$this->close();
}
}

Documentation des fonctions membres

JStream::_buildContext ( )

Stream contexts Builds the context from the array

Renvoie:
mixed
Depuis:
11.1

Définition à la ligne 920 du fichier stream.php.

{
// According to the manual this always works!
if (count($this->contextOptions))
{
$this->context = @stream_context_create($this->contextOptions);
}
else
{
$this->context = null;
}
}
JStream::_getFilename (   $filename,
  $mode,
  $use_prefix,
  $relative 
)

Determine the appropriate 'filename' of a file

Paramètres:
string$filenameOriginal filename of the file
string$modeMode string to retrieve the filename
boolean$use_prefixControls the use of a prefix
boolean$relativeDetermines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped.
Renvoie:
string
Depuis:
11.1

Définition à la ligne 1382 du fichier stream.php.

Références JFilesystemHelper\getWriteModes().

{
if ($use_prefix)
{
// Get rid of binary or t, should be at the end of the string
$tmode = trim($mode, 'btf123456789');
// Check if it's a write mode then add the appropriate prefix
// Get rid of JPATH_ROOT (legacy compat) along the way
if (in_array($tmode, JFilesystemHelper::getWriteModes()))
{
if (!$relative && $this->writeprefix)
{
$filename = str_replace(JPATH_ROOT, '', $filename);
}
$filename = $this->writeprefix . $filename;
}
else
{
if (!$relative && $this->readprefix)
{
$filename = str_replace(JPATH_ROOT, '', $filename);
}
$filename = $this->readprefix . $filename;
}
}
return $filename;
}

+ Voici le graphe d'appel pour cette fonction :

JStream::addContextEntry (   $wrapper,
  $name,
  $value 
)

Adds a particular options to the context

Paramètres:
string$wrapperThe wrapper to use
string$nameThe option to set
string$valueThe value of the option
Renvoie:
void
Voir également:
http://php.net/stream_context_create Stream Context Creation
http://php.net/manual/en/context.php Context Options for various streams
Depuis:
11.1

Définition à la ligne 964 du fichier stream.php.

{
$this->contextOptions[$wrapper][$name] = $value;
$this->_buildContext();
}
JStream::appendFilter (   $filtername,
  $read_write = STREAM_FILTER_READ,
  $params = array() 
)

Stream filters Append a filter to the chain

Paramètres:
string$filternameThe key name of the filter.
integer$read_writeOptional. Defaults to STREAM_FILTER_READ.
array$paramsAn array of params for the stream_filter_append call.
Renvoie:
mixed
Voir également:
http://php.net/manual/en/function.stream-filter-append.php
Depuis:
11.1

Définition à la ligne 1051 du fichier stream.php.

{
$res = false;
if ($this->fh)
{
// Capture PHP errors
$php_errormsg = '';
$track_errors = ini_get('track_errors');
ini_set('track_errors', true);
$res = @stream_filter_append($this->fh, $filtername, $read_write, $params);
if (!$res && $php_errormsg)
{
$this->setError($php_errormsg);
}
else
{
$this->filters[] = &$res;
}
// Restore error tracking to what it was before.
ini_set('track_errors', $track_errors);
}
return $res;
}
JStream::applyContextToStream ( )

Applies the current context to the stream

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

Renvoie:
mixed
Depuis:
11.1

Définition à la ligne 1014 du fichier stream.php.

{
$retval = false;
if ($this->fh)
{
// Capture PHP errors
$php_errormsg = 'Unknown error setting context option';
$track_errors = ini_get('track_errors');
ini_set('track_errors', true);
$retval = @stream_context_set_option($this->fh, $this->contextOptions);
if (!$retval)
{
$this->setError($php_errormsg);
}
// Restore error tracking to what it was before
ini_set('track_errors', $track_errors);
}
return $retval;
}
JStream::chmod (   $filename = '',
  $mode = 0 
)

Chmod wrapper

Paramètres:
string$filenameFile name.
mixed$modeMode to use.
Renvoie:
boolean
Depuis:
11.1

Définition à la ligne 834 du fichier stream.php.

Références JText\_(), et JFilesystemHelper\ftpChmod().

{
if (!$filename)
{
if (!isset($this->filename) || !$this->filename)
{
$this->setError(JText::_('JLIB_FILESYSTEM_ERROR_STREAMS_FILENAME'));
return false;
}
}
// If no mode is set use the default
if (!$mode)
{
$mode = $this->filemode;
}
$retval = false;
// Capture PHP errors
$php_errormsg = '';
$track_errors = ini_get('track_errors');
ini_set('track_errors', true);
$sch = parse_url($filename, PHP_URL_SCHEME);
// Scheme specific options; ftp's chmod support is fun.
switch ($sch)
{
case 'ftp':
case 'ftps':
break;
default:
$res = chmod($filename, $mode);
break;
}
// Seek, interestingly, returns 0 on success or -1 on failure
if (!$res)
{
$this->setError($php_errormsg);
}
else
{
$retval = true;
}
// Restore error tracking to what it was before.
ini_set('track_errors', $track_errors);
// Return the result
return $retval;
}

+ Voici le graphe d'appel pour cette fonction :

JStream::close ( )

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

Renvoie:
boolean
Depuis:
11.1

Définition à la ligne 305 du fichier stream.php.

Références JText\_().

{
if (!$this->fh)
{
$this->setError(JText::_('JLIB_FILESYSTEM_ERROR_STREAMS_FILE_NOT_OPEN'));
return true;
}
$retval = false;
// Capture PHP errors
$php_errormsg = 'Error Unknown';
$track_errors = ini_get('track_errors');
ini_set('track_errors', true);
switch ($this->processingmethod)
{
case 'gz':
$res = gzclose($this->fh);
break;
case 'bz':
$res = bzclose($this->fh);
break;
case 'f':
default:
$res = fclose($this->fh);
break;
}
if (!$res)
{
$this->setError($php_errormsg);
}
else
{
// Reset this
$this->fh = null;
$retval = true;
}
// If we wrote, chmod the file after it's closed
if ($this->openmode[0] == 'w')
{
$this->chmod();
}
// Restore error tracking to what it was before
ini_set('track_errors', $track_errors);
// Return the result
return $retval;
}

+ Voici le graphe d'appel pour cette fonction :

JStream::copy (   $src,
  $dest,
  $context = null,
  $use_prefix = true,
  $relative = false 
)

Copy a file from src to dest

Paramètres:
string$srcThe file path to copy from.
string$destThe file path to copy to.
resource$contextA valid context resource (optional) created with stream_context_create.
boolean$use_prefixControls the use of a prefix (optional).
boolean$relativeDetermines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped.
Renvoie:
mixed
Depuis:
11.1

Définition à la ligne 1173 du fichier stream.php.

{
// Capture PHP errors
$php_errormsg = '';
$track_errors = ini_get('track_errors');
ini_set('track_errors', true);
$chmodDest = $this->_getFilename($dest, 'w', $use_prefix, $relative);
// Since we're going to open the file directly we need to get the filename.
// We need to use the same prefix so force everything to write.
$src = $this->_getFilename($src, 'w', $use_prefix, $relative);
$dest = $this->_getFilename($dest, 'w', $use_prefix, $relative);
if ($context)
{
// Use the provided context
$res = @copy($src, $dest, $context);
}
elseif ($this->context)
{
// Use the objects context
$res = @copy($src, $dest, $this->context);
}
else
{
// Don't use any context
$res = @copy($src, $dest);
}
if (!$res && $php_errormsg)
{
$this->setError($php_errormsg);
}
else
{
$this->chmod($chmodDest);
}
// Restore error tracking to what it was before
ini_set('track_errors', $track_errors);
return $res;
}
JStream::delete (   $filename,
  $context = null,
  $use_prefix = true,
  $relative = false 
)

Delete a file

Paramètres:
string$filenameThe file path to delete.
resource$contextA valid context resource (optional) created with stream_context_create.
boolean$use_prefixControls the use of a prefix (optional).
boolean$relativeDetermines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped.
Renvoie:
mixed
Depuis:
11.1

Définition à la ligne 1282 du fichier stream.php.

{
// Capture PHP errors
$php_errormsg = '';
$track_errors = ini_get('track_errors');
ini_set('track_errors', true);
$filename = $this->_getFilename($filename, 'w', $use_prefix, $relative);
if ($context)
{
// Use the provided context
$res = @unlink($filename, $context);
}
elseif ($this->context)
{
// Use the object's context
$res = @unlink($filename, $this->context);
}
else
{
// Don't use any context
$res = @unlink($filename);
}
if (!$res && $php_errormsg)
{
$this->setError($php_errormsg());
}
// Restore error tracking to what it was before.
ini_set('track_errors', $track_errors);
return $res;
}
JStream::deleteContextEntry (   $wrapper,
  $name 
)

Deletes a particular setting from a context

Paramètres:
string$wrapperThe wrapper to use
string$nameThe option to unset
Renvoie:
void
Voir également:
http://php.net/stream_context_create
Depuis:
11.1

Définition à la ligne 981 du fichier stream.php.

{
// Check whether the wrapper is set
if (isset($this->contextOptions[$wrapper]))
{
// Check that entry is set for that wrapper
if (isset($this->contextOptions[$wrapper][$name]))
{
// Unset the item
unset($this->contextOptions[$wrapper][$name]);
// Check that there are still items there
if (!count($this->contextOptions[$wrapper]))
{
// Clean up an empty wrapper context option
unset($this->contextOptions[$wrapper]);
}
}
}
// Rebuild the context and apply it to the stream
$this->_buildContext();
}
JStream::eof ( )

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

Renvoie:
boolean
Depuis:
11.1

Définition à la ligne 368 du fichier stream.php.

Références JText\_().

{
if (!$this->fh)
{
$this->setError(JText::_('JLIB_FILESYSTEM_ERROR_STREAMS_FILE_NOT_OPEN'));
return false;
}
// Capture PHP errors
$php_errormsg = '';
$track_errors = ini_get('track_errors');
ini_set('track_errors', true);
switch ($this->processingmethod)
{
case 'gz':
$res = gzeof($this->fh);
break;
case 'bz':
case 'f':
default:
$res = feof($this->fh);
break;
}
if ($php_errormsg)
{
$this->setError($php_errormsg);
}
// Restore error tracking to what it was before
ini_set('track_errors', $track_errors);
// Return the result
return $res;
}

+ Voici le graphe d'appel pour cette fonction :

JStream::filesize ( )

Retrieve the file size of the path

Renvoie:
mixed
Depuis:
11.1

Définition à la ligne 414 du fichier stream.php.

Références JText\_(), et JFilesystemHelper\remotefsize().

{
if (!$this->filename)
{
$this->setError(JText::_('JLIB_FILESYSTEM_ERROR_STREAMS_FILE_NOT_OPEN'));
return false;
}
$retval = false;
// Capture PHP errors
$php_errormsg = '';
$track_errors = ini_get('track_errors');
ini_set('track_errors', true);
$res = @filesize($this->filename);
if (!$res)
{
$tmp_error = '';
if ($php_errormsg)
{
// Something went wrong.
// Store the error in case we need it.
$tmp_error = $php_errormsg;
}
$res = JFilesystemHelper::remotefsize($this->filename);
if (!$res)
{
if ($tmp_error)
{
// Use the php_errormsg from before
$this->setError($tmp_error);
}
else
{
// Error but nothing from php? How strange! Create our own
$this->setError(JText::_('JLIB_FILESYSTEM_ERROR_STREAMS_FILE_SIZE'));
}
}
else
{
$this->filesize = $res;
$retval = $res;
}
}
else
{
$this->filesize = $res;
$retval = $res;
}
// Restore error tracking to what it was before.
ini_set('track_errors', $track_errors);
// Return the result
return $retval;
}

+ Voici le graphe d'appel pour cette fonction :

JStream::get_meta_data ( )

Get the stream metadata

Renvoie:
array header/metadata
Voir également:
http://php.net/manual/en/function.stream-get-meta-data.php
Depuis:
11.1

Définition à la ligne 900 du fichier stream.php.

Références JText\_().

{
if (!$this->fh)
{
$this->setError(JText::_('JLIB_FILESYSTEM_ERROR_STREAMS_FILE_NOT_OPEN'));
return false;
}
return stream_get_meta_data($this->fh);
}

+ Voici le graphe d'appel pour cette fonction :

JStream::getFileHandle ( )

Return the internal file handle

Renvoie:
File handler
Depuis:
11.1

Définition à la ligne 1421 du fichier stream.php.

{
return $this->fh;
}
JStream::gets (   $length = 0)

Get a line from the stream source.

Paramètres:
integer$lengthThe number of bytes (optional) to read.
Renvoie:
mixed
Depuis:
11.1

Définition à la ligne 485 du fichier stream.php.

Références JText\_().

{
if (!$this->fh)
{
$this->setError(JText::_('JLIB_FILESYSTEM_ERROR_STREAMS_FILE_NOT_OPEN'));
return false;
}
$retval = false;
// Capture PHP errors
$php_errormsg = 'Error Unknown';
$track_errors = ini_get('track_errors');
ini_set('track_errors', true);
switch ($this->processingmethod)
{
case 'gz':
$res = $length ? gzgets($this->fh, $length) : gzgets($this->fh);
break;
case 'bz':
case 'f':
default:
$res = $length ? fgets($this->fh, $length) : fgets($this->fh);
break;
}
if (!$res)
{
$this->setError($php_errormsg);
}
else
{
$retval = $res;
}
// Restore error tracking to what it was before
ini_set('track_errors', $track_errors);
// Return the result
return $retval;
}

+ Voici le graphe d'appel pour cette fonction :

JStream::move (   $src,
  $dest,
  $context = null,
  $use_prefix = true,
  $relative = false 
)

Moves a file

Paramètres:
string$srcThe file path to move from.
string$destThe file path to move to.
resource$contextA valid context resource (optional) created with stream_context_create.
boolean$use_prefixControls the use of a prefix (optional).
boolean$relativeDetermines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped.
Renvoie:
mixed
Depuis:
11.1

Définition à la ligne 1231 du fichier stream.php.

{
// Capture PHP errors
$php_errormsg = '';
$track_errors = ini_get('track_errors');
ini_set('track_errors', true);
$src = $this->_getFilename($src, 'w', $use_prefix, $relative);
$dest = $this->_getFilename($dest, 'w', $use_prefix, $relative);
if ($context)
{
// Use the provided context
$res = @rename($src, $dest, $context);
}
elseif ($this->context)
{
// Use the object's context
$res = @rename($src, $dest, $this->context);
}
else
{
// Don't use any context
$res = @rename($src, $dest);
}
if (!$res && $php_errormsg)
{
$this->setError($php_errormsg());
}
$this->chmod($dest);
// Restore error tracking to what it was before
ini_set('track_errors', $track_errors);
return $res;
}
JStream::open (   $filename,
  $mode = 'r',
  $use_include_path = false,
  $context = null,
  $use_prefix = false,
  $relative = false,
  $detectprocessingmode = false 
)

Generic File Operations

Open a stream with some lazy loading smarts

Paramètres:
string$filenameFilename
string$modeMode string to use
boolean$use_include_pathUse the PHP include path
resource$contextContext to use when opening
boolean$use_prefixUse a prefix to open the file
boolean$relativeFilename is a relative path (if false, strips JPATH_ROOT to make it relative)
boolean$detectprocessingmodeDetect the processing method for the file and use the appropriate function to handle output automatically
Renvoie:
boolean
Depuis:
11.1

Définition à la ligne 186 du fichier stream.php.

Références JText\_(), JFile\getExt(), et JFilesystemHelper\isJoomlaStream().

{
$filename = $this->_getFilename($filename, $mode, $use_prefix, $relative);
if (!$filename)
{
$this->setError(JText::_('JLIB_FILESYSTEM_ERROR_STREAMS_FILENAME'));
return false;
}
$this->filename = $filename;
$this->openmode = $mode;
$url = parse_url($filename);
$retval = false;
if (isset($url['scheme']))
{
// If we're dealing with a Joomla! stream, load it
if (JFilesystemHelper::isJoomlaStream($url['scheme']))
{
require_once __DIR__ . '/streams/' . $url['scheme'] . '.php';
}
// We have a scheme! force the method to be f
$this->processingmethod = 'f';
}
elseif ($detectprocessingmode)
{
$ext = strtolower(JFile::getExt($this->filename));
switch ($ext)
{
case 'tgz':
case 'gz':
case 'gzip':
$this->processingmethod = 'gz';
break;
case 'tbz2':
case 'bz2':
case 'bzip2':
$this->processingmethod = 'bz';
break;
default:
$this->processingmethod = 'f';
break;
}
}
// Capture PHP errors
$php_errormsg = 'Error Unknown whilst opening a file';
$track_errors = ini_get('track_errors');
ini_set('track_errors', true);
// Decide which context to use:
switch ($this->processingmethod)
{
// Gzip doesn't support contexts or streams
case 'gz':
$this->fh = gzopen($filename, $mode, $use_include_path);
break;
// Bzip2 is much like gzip except it doesn't use the include path
case 'bz':
$this->fh = bzopen($filename, $mode);
break;
// Fopen can handle streams
case 'f':
default:
// One supplied at open; overrides everything
if ($context)
{
$this->fh = fopen($filename, $mode, $use_include_path, $context);
}
// One provided at initialisation
elseif ($this->context)
{
$this->fh = fopen($filename, $mode, $use_include_path, $this->context);
}
// No context; all defaults
else
{
$this->fh = fopen($filename, $mode, $use_include_path);
}
break;
}
if (!$this->fh)
{
$this->setError($php_errormsg);
}
else
{
$retval = true;
}
// Restore error tracking to what it was before
ini_set('track_errors', $track_errors);
// Return the result
return $retval;
}

+ Voici le graphe d'appel pour cette fonction :

JStream::prependFilter (   $filtername,
  $read_write = STREAM_FILTER_READ,
  $params = array() 
)

Prepend a filter to the chain

Paramètres:
string$filternameThe key name of the filter.
integer$read_writeOptional. Defaults to STREAM_FILTER_READ.
array$paramsAn array of params for the stream_filter_prepend call.
Renvoie:
mixed
Voir également:
http://php.net/manual/en/function.stream-filter-prepend.php
Depuis:
11.1

Définition à la ligne 1092 du fichier stream.php.

{
$res = false;
if ($this->fh)
{
// Capture PHP errors
$php_errormsg = '';
$track_errors = ini_get('track_errors');
ini_set('track_errors', true);
$res = @stream_filter_prepend($this->fh, $filtername, $read_write, $params);
if (!$res && $php_errormsg)
{
// Set the error msg
$this->setError($php_errormsg);
}
else
{
array_unshift($res, '');
$res[0] = &$this->filters;
}
// Restore error tracking to what it was before.
ini_set('track_errors', $track_errors);
}
return $res;
}
JStream::read (   $length = 0)

Read a file

Handles user space streams appropriately otherwise any read will return 8192

Paramètres:
integer$lengthLength of data to read
Renvoie:
mixed
Voir également:
http://php.net/manual/en/function.fread.php
Depuis:
11.1

Définition à la ligne 542 du fichier stream.php.

Références JText\_().

{
if (!$this->filesize && !$length)
{
// Get the filesize
$this->filesize();
if (!$this->filesize)
{
// Set it to the biggest and then wait until eof
$length = -1;
}
else
{
$length = $this->filesize;
}
}
if (!$this->fh)
{
$this->setError(JText::_('JLIB_FILESYSTEM_ERROR_STREAMS_FILE_NOT_OPEN'));
return false;
}
$retval = false;
// Capture PHP errors
$php_errormsg = 'Error Unknown';
$track_errors = ini_get('track_errors');
ini_set('track_errors', true);
$remaining = $length;
do
{
// Do chunked reads where relevant
switch ($this->processingmethod)
{
case 'bz':
$res = ($remaining > 0) ? bzread($this->fh, $remaining) : bzread($this->fh, $this->chunksize);
break;
case 'gz':
$res = ($remaining > 0) ? gzread($this->fh, $remaining) : gzread($this->fh, $this->chunksize);
break;
case 'f':
default:
$res = ($remaining > 0) ? fread($this->fh, $remaining) : fread($this->fh, $this->chunksize);
break;
}
if (!$res)
{
$this->setError($php_errormsg);
// Jump from the loop
$remaining = 0;
}
else
{
if (!$retval)
{
$retval = '';
}
$retval .= $res;
if (!$this->eof())
{
$len = strlen($res);
$remaining -= $len;
}
else
{
// If it's the end of the file then we've nothing left to read; reset remaining and len
$remaining = 0;
$length = strlen($retval);
}
}
}
while ($remaining || !$length);
// Restore error tracking to what it was before
ini_set('track_errors', $track_errors);
// Return the result
return $retval;
}

+ Voici le graphe d'appel pour cette fonction :

JStream::removeFilter ( $resource,
  $byindex = false 
)

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

Paramètres:
resource&$resourceThe resource.
boolean$byindexThe index of the filter.
Renvoie:
boolean Result of operation
Depuis:
11.1

Définition à la ligne 1133 du fichier stream.php.

{
// Capture PHP errors
$php_errormsg = '';
$track_errors = ini_get('track_errors');
ini_set('track_errors', true);
if ($byindex)
{
$res = stream_filter_remove($this->filters[$resource]);
}
else
{
$res = stream_filter_remove($resource);
}
if ($res && $php_errormsg)
{
$this->setError($php_errormsg);
}
// Restore error tracking to what it was before.
ini_set('track_errors', $track_errors);
return $res;
}
JStream::seek (   $offset,
  $whence = SEEK_SET 
)

Seek the file

Note: the return value is different to that of fseek

Paramètres:
integer$offsetOffset to use when seeking.
integer$whenceSeek mode to use.
Renvoie:
boolean True on success, false on failure
Voir également:
http://php.net/manual/en/function.fseek.php
Depuis:
11.1

Définition à la ligne 645 du fichier stream.php.

Références JText\_().

{
if (!$this->fh)
{
$this->setError(JText::_('JLIB_FILESYSTEM_ERROR_STREAMS_FILE_NOT_OPEN'));
return false;
}
$retval = false;
// Capture PHP errors
$php_errormsg = '';
$track_errors = ini_get('track_errors');
ini_set('track_errors', true);
switch ($this->processingmethod)
{
case 'gz':
$res = gzseek($this->fh, $offset, $whence);
break;
case 'bz':
case 'f':
default:
$res = fseek($this->fh, $offset, $whence);
break;
}
// Seek, interestingly, returns 0 on success or -1 on failure.
if ($res == -1)
{
$this->setError($php_errormsg);
}
else
{
$retval = true;
}
// Restore error tracking to what it was before
ini_set('track_errors', $track_errors);
// Return the result
return $retval;
}

+ Voici le graphe d'appel pour cette fonction :

JStream::setContextOptions (   $context)

Updates the context to the array

Format is the same as the options for stream_context_create

Paramètres:
array$contextOptions to create the context with
Renvoie:
void
Voir également:
http://php.net/stream_context_create
Depuis:
11.1

Définition à la ligne 945 du fichier stream.php.

{
$this->contextOptions = $context;
$this->_buildContext();
}
JStream::tell ( )

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

Renvoie:
mixed
Depuis:
11.1

Définition à la ligne 698 du fichier stream.php.

Références JText\_().

{
if (!$this->fh)
{
$this->setError(JText::_('JLIB_FILESYSTEM_ERROR_STREAMS_FILE_NOT_OPEN'));
return false;
}
// Capture PHP errors
$php_errormsg = '';
$track_errors = ini_get('track_errors');
ini_set('track_errors', true);
switch ($this->processingmethod)
{
case 'gz':
$res = gztell($this->fh);
break;
case 'bz':
case 'f':
default:
$res = ftell($this->fh);
break;
}
// May return 0 so check if it's really false
if ($res === false)
{
$this->setError($php_errormsg);
}
// Restore error tracking to what it was before
ini_set('track_errors', $track_errors);
// Return the result
return $res;
}

+ Voici le graphe d'appel pour cette fonction :

JStream::upload (   $src,
  $dest,
  $context = null,
  $use_prefix = true,
  $relative = false 
)

Upload a file

Paramètres:
string$srcThe file path to copy from (usually a temp folder).
string$destThe file path to copy to.
resource$contextA valid context resource (optional) created with stream_context_create.
boolean$use_prefixControls the use of a prefix (optional).
boolean$relativeDetermines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped.
Renvoie:
mixed
Depuis:
11.1

Définition à la ligne 1331 du fichier stream.php.

Références JText\_().

{
if (is_uploaded_file($src))
{
// Make sure it's an uploaded file
return $this->copy($src, $dest, $context, $use_prefix, $relative);
}
else
{
$this->setError(JText::_('JLIB_FILESYSTEM_ERROR_STREAMS_NOT_UPLOADED_FILE'));
return false;
}
}

+ Voici le graphe d'appel pour cette fonction :

JStream::write ( $string,
  $length = 0,
  $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

Paramètres:
string&$stringReference to the string to write.
integer$lengthLength of the string to write.
integer$chunkSize of chunks to write in.
Renvoie:
boolean
Voir également:
http://php.net/manual/en/function.fwrite.php
Depuis:
11.1

Définition à la ligne 758 du fichier stream.php.

Références JText\_().

{
if (!$this->fh)
{
$this->setError(JText::_('JLIB_FILESYSTEM_ERROR_STREAMS_FILE_NOT_OPEN'));
return false;
}
// If the length isn't set, set it to the length of the string.
if (!$length)
{
$length = strlen($string);
}
// If the chunk isn't set, set it to the default.
if (!$chunk)
{
$chunk = $this->chunksize;
}
$retval = true;
// Capture PHP errors
$php_errormsg = '';
$track_errors = ini_get('track_errors');
ini_set('track_errors', true);
$remaining = $length;
$start = 0;
do
{
// If the amount remaining is greater than the chunk size, then use the chunk
$amount = ($remaining > $chunk) ? $chunk : $remaining;
$res = fwrite($this->fh, substr($string, $start), $amount);
// Returns false on error or the number of bytes written
if ($res === false)
{
// Returned error
$this->setError($php_errormsg);
$retval = false;
$remaining = 0;
}
elseif ($res === 0)
{
// Wrote nothing?
$remaining = 0;
$this->setError(JText::_('JLIB_FILESYSTEM_ERROR_NO_DATA_WRITTEN'));
}
else
{
// Wrote something
$start += $amount;
$remaining -= $res;
}
}
while ($remaining);
// Restore error tracking to what it was before.
ini_set('track_errors', $track_errors);
// Return the result
return $retval;
}

+ Voici le graphe d'appel pour cette fonction :

JStream::writeFile (   $filename,
$buffer 
)

Writes a chunk of data to a file.

Paramètres:
string$filenameThe file name.
string&$bufferThe data to write to the file.
Renvoie:
boolean
Depuis:
11.1

Définition à la ligne 1356 du fichier stream.php.

{
if ($this->open($filename, 'w'))
{
$result = $this->write($buffer);
$this->chmod();
$this->close();
return $result;
}
return false;
}

Documentation des données membres

JStream::$chunksize = 8192
protected

Définition à la ligne 54 du fichier stream.php.

JStream::$context = null
protected

Définition à la ligne 119 du fichier stream.php.

JStream::$contextOptions
protected

Définition à la ligne 127 du fichier stream.php.

JStream::$dirmode = 0755
protected

Définition à la ligne 46 du fichier stream.php.

JStream::$fh
protected

Définition à la ligne 103 du fichier stream.php.

JStream::$filemode = 0644
protected

Définition à la ligne 38 du fichier stream.php.

JStream::$filename
protected

Définition à la ligne 62 du fichier stream.php.

JStream::$filesize
protected

Définition à la ligne 111 du fichier stream.php.

JStream::$filters = array()
protected

Définition à la ligne 95 du fichier stream.php.

JStream::$openmode
protected

Définition à la ligne 135 du fichier stream.php.

JStream::$processingmethod = 'f'
protected

Définition à la ligne 87 du fichier stream.php.

JStream::$readprefix
protected

Définition à la ligne 78 du fichier stream.php.

JStream::$writeprefix
protected

Définition à la ligne 70 du fichier stream.php.


La documentation de cette classe a été générée à partir du fichier suivant :