[ Index ] |
|
Code source de PRADO 3.0.6 |
1 <?php 2 /** 3 * Zend Framework 4 * 5 * LICENSE 6 * 7 * This source file is subject to version 1.0 of the Zend Framework 8 * license, that is bundled with this package in the file LICENSE, and 9 * is available through the world-wide-web at the following URL: 10 * http://www.zend.com/license/framework/1_0.txt. If you did not receive 11 * a copy of the Zend Framework license and are unable to obtain it 12 * through the world-wide-web, please send a note to license@zend.com 13 * so we can mail you a copy immediately. 14 * 15 * @package Zend_Search_Lucene 16 * @subpackage Storage 17 * @copyright Copyright (c) 2005-2006 Zend Technologies USA Inc. (http://www.zend.com) 18 * @license http://www.zend.com/license/framework/1_0.txt Zend Framework License version 1.0 19 */ 20 21 22 /** Zend_Search_Lucene_Storage_File */ 23 require_once 'Zend/Search/Lucene/Storage/File.php'; 24 25 /** Zend_Search_Lucene_Exception */ 26 require_once 'Zend/Search/Lucene/Exception.php'; 27 28 29 /** 30 * @package Zend_Search_Lucene 31 * @subpackage Storage 32 * @copyright Copyright (c) 2005-2006 Zend Technologies USA Inc. (http://www.zend.com) 33 * @license http://www.zend.com/license/framework/1_0.txt Zend Framework License version 1.0 34 * 35 */ 36 class Zend_Search_Lucene_Storage_File_Filesystem extends Zend_Search_Lucene_Storage_File 37 { 38 /** 39 * Resource of the open file 40 * 41 * @var resource 42 */ 43 private $_fileHandle; 44 45 46 /** 47 * Class constructor. Open the file. 48 * 49 * @param string $filename 50 * @param string $mode 51 */ 52 public function __construct($filename, $mode='rb') 53 { 54 global $php_errormsg; 55 56 $trackErrors = ini_get( "track_errors"); 57 ini_set('track_errors', '1'); 58 59 $this->_fileHandle = @fopen($filename, $mode); 60 61 if ($this->_fileHandle===false) { 62 ini_set('track_errors', $trackErrors); 63 throw new Zend_Search_Lucene_Exception($php_errormsg); 64 } 65 66 ini_set('track_errors', $trackErrors); 67 } 68 69 70 /** 71 * Sets the file position indicator and advances the file pointer. 72 * The new position, measured in bytes from the beginning of the file, 73 * is obtained by adding offset to the position specified by whence, 74 * whose values are defined as follows: 75 * SEEK_SET - Set position equal to offset bytes. 76 * SEEK_CUR - Set position to current location plus offset. 77 * SEEK_END - Set position to end-of-file plus offset. (To move to 78 * a position before the end-of-file, you need to pass a negative value 79 * in offset.) 80 * Upon success, returns 0; otherwise, returns -1 81 * 82 * @param integer $offset 83 * @param integer $whence 84 * @return integer 85 */ 86 public function seek($offset, $whence=SEEK_SET) 87 { 88 return fseek($this->_fileHandle, $offset, $whence); 89 } 90 91 92 /** 93 * Get file position. 94 * 95 * @return integer 96 */ 97 public function tell() 98 { 99 return ftell($this->_fileHandle); 100 } 101 102 103 /** 104 * Close File object 105 */ 106 public function close() 107 { 108 if ($this->_fileHandle !== null ) { 109 @fclose($this->_fileHandle); 110 $this->_fileHandle = null; 111 } 112 } 113 114 /** 115 * Get the size of the already opened file 116 * 117 * @return integer 118 */ 119 public function size() 120 { 121 $position = ftell($this->_fileHandle); 122 fseek($this->_fileHandle, 0, SEEK_END); 123 $size = ftell($this->_fileHandle); 124 fseek($this->_fileHandle,$position); 125 126 return $size; 127 } 128 129 /** 130 * Read a $length bytes from the file and advance the file pointer. 131 * 132 * @param integer $length 133 * @return string 134 */ 135 protected function _fread($length=1) 136 { 137 if ($length == 0) { 138 return ''; 139 } 140 141 if ($length < 1024) { 142 return fread($this->_fileHandle, $length); 143 } 144 145 $data = ''; 146 while ( $length > 0 && ($nextBlock = fread($this->_fileHandle, $length)) != false ) { 147 $data .= $nextBlock; 148 $length -= strlen($nextBlock); 149 } 150 return $data; 151 } 152 153 154 /** 155 * Writes $length number of bytes (all, if $length===null) to the end 156 * of the file. 157 * 158 * @param string $data 159 * @param integer $length 160 */ 161 protected function _fwrite($data, $length=null) 162 { 163 if ($length === null ) { 164 fwrite($this->_fileHandle, $data); 165 } else { 166 fwrite($this->_fileHandle, $data, $length); 167 } 168 } 169 } 170
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 21:07:04 2007 | par Balluche grâce à PHPXref 0.7 |