- Timestamp:
- 19.10.2005 19:06:23 (3 years ago)
- Location:
- trunk
- Files:
-
- 3 modified
-
File/Bittorrent/Decode.php (modified) (5 diffs)
-
File/Bittorrent/MakeTorrent.php (modified) (8 diffs)
-
example_mktorrent.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/File/Bittorrent/Decode.php
r48 r49 145 145 146 146 /** 147 * @var mixed The last error object or null if no error has occurred. 148 */ 149 var $last_error; 150 151 /** 147 152 * Decode a Bencoded string 148 153 * … … 168 173 // Check file 169 174 if (!is_file($file)) { 170 PEAR::raiseError('File_Bittorrent_Decode::decode() - Not a file.', null, null, "Given filename '$file' is not a valid file.");175 $this->last_error = PEAR::raiseError('File_Bittorrent_Decode::decode() - Not a file.', null, null, "Given filename '$file' is not a valid file."); 171 176 return false; 172 177 } … … 190 195 $decoded = $this->_bdecode(); 191 196 if (!is_array($decoded)) { 192 PEAR::raiseError('File_Bittorrent_Decode::decode() - Corrupted bencoded data.', null, null, "Failed to decode data from file '$file'.");197 $this->last_error = PEAR::raiseError('File_Bittorrent_Decode::decode() - Corrupted bencoded data.', null, null, "Failed to decode data from file '$file'."); 193 198 return false; 194 199 } … … 409 414 // Check if we can access remote data 410 415 if (!ini_get('allow_url_fopen')) { 411 PEAR::raiseError('File_Bittorrent_Decode::getStats() - "allow_url_fopen" must be enabled.');416 $this->last_error = PEAR::raiseError('File_Bittorrent_Decode::getStats() - "allow_url_fopen" must be enabled.'); 412 417 return false; 413 418 } … … 418 423 $stats = $this->decode($scrape_data); 419 424 if (!isset($stats['files'][$packed_hash])) { 420 PEAR::raiseError('File_Bittorrent_Decode::getStats() - Invalid scrape data: "' . $scrape_data . '"');425 $this->last_error = PEAR::raiseError('File_Bittorrent_Decode::getStats() - Invalid scrape data: "' . $scrape_data . '"'); 421 426 return false; 422 427 } -
trunk/File/Bittorrent/MakeTorrent.php
r42 r49 134 134 135 135 /** 136 * @var mixed The last error object or null if no error has occurred. 137 */ 138 var $last_error; 139 140 /** 136 141 * Constructor 137 142 * … … 169 174 { 170 175 if (!is_array($announce_list)) { 171 PEAR::raiseError(__CLASS__ . '::'. __FUNCTION__ . '() - No array given.');176 $this->last_error = PEAR::raiseError(__CLASS__ . '::'. __FUNCTION__ . '() - No array given.'); 172 177 return false; 173 178 } … … 223 228 { 224 229 if ($piece_length < 32 or $piece_length > 4096) { 225 PEAR::raiseError(__CLASS__ . '::'. __FUNCTION__ . '() - Invalid piece lenth: "' . $piece_length . '"');230 $this->last_error = PEAR::raiseError(__CLASS__ . '::'. __FUNCTION__ . '() - Invalid piece lenth: "' . $piece_length . '"'); 226 231 return false; 227 232 } … … 251 256 } 252 257 $metainfo = $this->_encodeTorrent(); 258 } else { 259 $this->last_error = PEAR::raiseError(__CLASS__ . '::'. __FUNCTION__ . '() - You must provide a file or directory.'); 260 return false; 253 261 } 254 262 return $metainfo; … … 277 285 $bencdata['info']['files'] = $this->_files; 278 286 } else { 279 PEAR::raiseError(__CLASS__ . '::'. __FUNCTION__ . '() - Use ' . __CLASS__ . '::setPath() to define a file or directory.');287 $this->last_error = PEAR::raiseError(__CLASS__ . '::'. __FUNCTION__ . '() - Use ' . __CLASS__ . '::setPath() to define a file or directory.'); 280 288 return false; 281 289 } … … 303 311 function _addFile($file) 304 312 { 305 if (!$this->_openFile($file)) return false; 313 if (!$this->_openFile($file)) { 314 $this->last_error = PEAR::raiseError(__CLASS__ . '::'. __FUNCTION__ . "() - Failed to open file '$file'."); 315 return false; 316 } 306 317 307 318 $filelength = 0; … … 452 463 if ($fsize <= 2*1024*1024*1024) { 453 464 if (!$this->_fp = fopen($file, 'r')) { 454 PEAR::raiseError(__CLASS__ . '::'. __FUNCTION__ . '() - Failed to open "' . $file . '"');465 $this->last_error = PEAR::raiseError(__CLASS__ . '::'. __FUNCTION__ . '() - Failed to open "' . $file . '"'); 455 466 return false; 456 467 } … … 458 469 } else { 459 470 if (PHP_OS != 'Linux') { 460 PEAR::raiseError(__CLASS__ . '::'. __FUNCTION__ . '() - File size is greater than 2GB. This is only supported under Linux.');471 $this->last_error = PEAR::raiseError(__CLASS__ . '::'. __FUNCTION__ . '() - File size is greater than 2GB. This is only supported under Linux.'); 461 472 return false; 462 473 } -
trunk/example_mktorrent.php
r26 r49 4 4 5 5 require_once 'File/Bittorrent/MakeTorrent.php'; 6 7 // Set error handling 8 PEAR::setErrorHandling(PEAR_ERROR_PRINT); 9 6 10 $MakeTorrent = new File_Bittorrent_MakeTorrent('example.php'); 7 11