Tagged 0.7.5
[scuttle] / includes / php-gettext / streams.php
index d57aac6496b2b1da2419cff07f2d04de9455bd56..3cdc1584e1fa57451596c59a55f1dd03dc1a7939 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /*
-   Copyright (c) 2003, 2005 Danilo Segan <danilo@kvota.net>.
+   Copyright (c) 2003, 2005, 2006, 2009 Danilo Segan <danilo@kvota.net>.
 
    This file is part of PHP-gettext.
 
 */
 
 
-// Simple class to wrap file streams, string streams, etc.
-// seek is essential, and it should be byte stream
+  // Simple class to wrap file streams, string streams, etc.
+  // seek is essential, and it should be byte stream
 class StreamReader {
   // should return a string [FIXME: perhaps return array of bytes?]
   function read($bytes) {
     return false;
   }
-  
+
   // should return new position
   function seekto($position) {
     return false;
   }
-  
+
   // returns current position
   function currentpos() {
     return false;
   }
-  
+
   // returns length of entire stream (limit for seekto()s)
   function length() {
     return false;
   }
-}
+};
 
 class StringReader {
   var $_pos;
@@ -78,7 +78,7 @@ class StringReader {
     return strlen($this->_str);
   }
 
-}
+};
 
 
 class FileReader {
@@ -93,8 +93,8 @@ class FileReader {
       $this->_pos = 0;
       $this->_fd = fopen($filename,'rb');
       if (!$this->_fd) {
-       $this->error = 3; // Cannot read file, probably permissions
-       return false;
+        $this->error = 3; // Cannot read file, probably permissions
+        return false;
       }
     } else {
       $this->error = 2; // File doesn't exist
@@ -108,13 +108,14 @@ class FileReader {
 
       // PHP 5.1.1 does not read more than 8192 bytes in one fread()
       // the discussions at PHP Bugs suggest it's the intended behaviour
+      $data = '';
       while ($bytes > 0) {
         $chunk  = fread($this->_fd, $bytes);
         $data  .= $chunk;
         $bytes -= strlen($chunk);
       }
       $this->_pos = ftell($this->_fd);
-      
+
       return $data;
     } else return '';
   }
@@ -137,9 +138,9 @@ class FileReader {
     fclose($this->_fd);
   }
 
-}
+};
 
-// Preloads entire file in memory first, then creates a StringReader 
+// Preloads entire file in memory first, then creates a StringReader
 // over it (it assumes knowledge of StringReader internals)
 class CachedFileReader extends StringReader {
   function CachedFileReader($filename) {
@@ -149,8 +150,8 @@ class CachedFileReader extends StringReader {
       $fd = fopen($filename,'rb');
 
       if (!$fd) {
-       $this->error = 3; // Cannot read file, probably permissions
-       return false;
+        $this->error = 3; // Cannot read file, probably permissions
+        return false;
       }
       $this->_str = fread($fd, $length);
       fclose($fd);
@@ -160,7 +161,7 @@ class CachedFileReader extends StringReader {
       return false;
     }
   }
-}
+};
 
 
-?>
\ No newline at end of file
+?>

Benjamin Mako Hill || Want to submit a patch?