WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/28/2005 04:31:01 PM (14 years ago)
Author:
ryan
Message:

Bump php-gettext to version 1.0.3. http://mosquito.wordpress.org/view.php?id=1001 Mad props to Nico Kaiser.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/streams.php

    r1080 r2394  
    11<?php
    22/*
    3    Copyright (c) 2003 Danilo Segan <danilo@kvota.net>.
     3   Copyright (c) 2003, 2005 Danilo Segan <danilo@kvota.net>.
    44
    55   This file is part of PHP-gettext.
     
    104104
    105105  function read($bytes) {
    106     fseek($this->_fd, $this->_pos);
    107     $data = fread($this->_fd, $bytes);
    108     $this->_pos = ftell($this->_fd);
    109 
    110     return $data;
     106    if ($bytes) {
     107      fseek($this->_fd, $this->_pos);
     108      $data = fread($this->_fd, $bytes);
     109      $this->_pos = ftell($this->_fd);
     110     
     111      return $data;
     112    } else return '';
    111113  }
    112114
     
    131133}
    132134
     135// Preloads entire file in memory first, then creates a StringReader
     136// over it (it assumes knowledge of StringReader internals)
     137class CachedFileReader extends StringReader {
     138  function CachedFileReader($filename) {
     139    if (file_exists($filename)) {
     140
     141      $length=filesize($filename);
     142      $fd = fopen($filename,'rb');
     143
     144      if (!$fd) {
     145    $this->error = 3; // Cannot read file, probably permissions
     146    return false;
     147      }
     148      $this->_str = fread($fd, $length);
     149      fclose($fd);
     150
     151    } else {
     152      $this->error = 2; // File doesn't exist
     153      return false;
     154    }
     155  }
     156}
     157
     158
    133159?>
Note: See TracChangeset for help on using the changeset viewer.