Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: Joomla-Framework

Developer Network License

The Joomla! Developer Network content is © copyright 2006 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5
Source code for file /joomla/utilities/buffer.php

Documentation is available at buffer.php

  1. <?php
  2. /**
  3.  * @version        $Id: archive.php 6138 2007-01-02 03:44:18Z eddiea $
  4.  * @package        Joomla.Framework
  5.  * @subpackage    Utilities
  6.  * @copyright    Copyright (C) 2005 - 2007 Open Source Matters. All rights reserved.
  7.  * @license        GNU/GPL, see LICENSE.php
  8.  *  Joomla! is free software. This version may have been modified pursuant
  9.  *  to the GNU General Public License, and as distributed it includes or
  10.  *  is derivative of works licensed under the GNU General Public License or
  11.  *  other free or open source software licenses.
  12.  *  See COPYRIGHT.php for copyright notices and details.
  13.  */
  14.  
  15. /**
  16.  * Generic Buffer stream handler
  17.  *
  18.  * This class provides a generic buffer stream.  It can be used to store/retrieve/manipulate string buffers with the standard
  19.  * PHP filesystem I/O methods.
  20.  *
  21.  * @author        Louis Landry <[email protected]>
  22.  * @package     Joomla.Framework
  23.  * @subpackage    Utilities
  24.  * @since        1.5
  25.  */
  26. {
  27.     /**
  28.      * Stream position
  29.      * @var int 
  30.      */
  31.     var $position = 0;
  32.  
  33.     /**
  34.      * Buffer name
  35.      * @var string 
  36.      */
  37.     var $name = null;
  38.  
  39.     /**
  40.      * Buffer hash
  41.      * @var array 
  42.      */
  43.     var $_buffers = array ();
  44.  
  45.     function stream_open($path$mode$options$opened_path{
  46.         $url parse_url($path);
  47.         $this->name = $url["host"];
  48.         $this->_buffers[$this->namenull;
  49.         $this->position = 0;
  50.  
  51.         return true;
  52.     }
  53.  
  54.     function stream_read($count{
  55.         $ret substr($this->_buffers[$this->name]$this->position$count);
  56.         $this->position += strlen($ret);
  57.         return $ret;
  58.     }
  59.  
  60.     function stream_write($data{
  61.         $left substr($this->_buffers[$this->name]0$this->position);
  62.         $right substr($this->_buffers[$this->name]$this->position + strlen($data));
  63.         $this->_buffers[$this->name$left $data $right;
  64.         $this->position += strlen($data);
  65.         return strlen($data);
  66.     }
  67.  
  68.     function stream_tell({
  69.         return $this->position;
  70.     }
  71.  
  72.     function stream_eof({
  73.         return $this->position >= strlen($this->_buffers[$this->name]);
  74.     }
  75.  
  76.     function stream_seek($offset$whence{
  77.         switch ($whence{
  78.             case SEEK_SET :
  79.                 if ($offset strlen($this->_buffers[$this->name]&& $offset >= 0{
  80.                     $this->position = $offset;
  81.                     return true;
  82.                 else {
  83.                     return false;
  84.                 }
  85.                 break;
  86.  
  87.             case SEEK_CUR :
  88.                 if ($offset >= 0{
  89.                     $this->position += $offset;
  90.                     return true;
  91.                 else {
  92.                     return false;
  93.                 }
  94.                 break;
  95.  
  96.             case SEEK_END :
  97.                 if (strlen($this->_buffers[$this->name]$offset >= 0{
  98.                     $this->position = strlen($this->_buffers[$this->name]$offset;
  99.                     return true;
  100.                 else {
  101.                     return false;
  102.                 }
  103.                 break;
  104.  
  105.             default :
  106.                 return false;
  107.         }
  108.     }
  109. }
  110. // Register the stream
  111. stream_wrapper_register("buffer""JBufferStream");
  112. ?>

Documentation generated on Mon, 05 Mar 2007 20:53:31 +0000 by phpDocumentor 1.3.1