| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id:buffer.php 6961 2007-03-15 16:06:53Z tcp $ 4 * @package Joomla.Framework 5 * @subpackage Utilities 6 * @copyright Copyright (C) 2005 - 2010 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 defined('JPATH_BASE') or die(); 15 /** 16 * Generic Buffer stream handler 17 * 18 * This class provides a generic buffer stream. It can be used to store/retrieve/manipulate 19 * string buffers with the standard PHP filesystem I/O methods. 20 * 21 * @package Joomla.Framework 22 * @subpackage Utilities 23 * @since 1.5 24 */ 25 class JBuffer 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 { 47 $url = parse_url($path); 48 $this->name = $url["host"]; 49 $this->_buffers[$this->name] = null; 50 $this->position = 0; 51 52 return true; 53 } 54 55 function stream_read($count) 56 { 57 $ret = substr($this->_buffers[$this->name], $this->position, $count); 58 $this->position += strlen($ret); 59 return $ret; 60 } 61 62 function stream_write($data) 63 { 64 $left = substr($this->_buffers[$this->name], 0, $this->position); 65 $right = substr($this->_buffers[$this->name], $this->position + strlen($data)); 66 $this->_buffers[$this->name] = $left . $data . $right; 67 $this->position += strlen($data); 68 return strlen($data); 69 } 70 71 function stream_tell() { 72 return $this->position; 73 } 74 75 function stream_eof() { 76 return $this->position >= strlen($this->_buffers[$this->name]); 77 } 78 79 function stream_seek($offset, $whence) 80 { 81 switch ($whence) 82 { 83 case SEEK_SET : 84 if ($offset < strlen($this->_buffers[$this->name]) && $offset >= 0) { 85 $this->position = $offset; 86 return true; 87 } else { 88 return false; 89 } 90 break; 91 92 case SEEK_CUR : 93 if ($offset >= 0) { 94 $this->position += $offset; 95 return true; 96 } else { 97 return false; 98 } 99 break; 100 101 case SEEK_END : 102 if (strlen($this->_buffers[$this->name]) + $offset >= 0) { 103 $this->position = strlen($this->_buffers[$this->name]) + $offset; 104 return true; 105 } else { 106 return false; 107 } 108 break; 109 110 default : 111 return false; 112 } 113 } 114 } 115 // Register the stream 116 stream_wrapper_register("buffer", "JBuffer");
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |