[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/libraries/domit/ -> php_file_utilities.php (source)

   1  <?php
   2  
   3  if (!defined('PHP_TEXT_CACHE_INCLUDE_PATH')) {
   4      define('PHP_TEXT_CACHE_INCLUDE_PATH', (dirname(__FILE__) . "/"));
   5  }
   6  
   7  class php_file_utilities {
   8      /**
   9      * Retrieves binary or text data from the specified file
  10      * @param string The file path
  11      * @param string The attributes for the read operation ('r' or 'rb' or 'rt')
  12      * @return mixed he text or binary data contained in the file
  13      */
  14      function &getDataFromFile($filename, $readAttributes, $readSize = 8192) {
  15          $fileContents = null;
  16          $fileHandle = @fopen($filename, $readAttributes);
  17  
  18          if($fileHandle){
  19              do {
  20                  $data = fread($fileHandle, $readSize);
  21  
  22                  if (strlen($data) == 0) {
  23                      break;
  24                  }
  25  
  26                  $fileContents .= $data;
  27              } while (true);
  28  
  29              fclose($fileHandle);
  30          }
  31  
  32          return $fileContents;
  33      } //getDataFromFile
  34  
  35      /**
  36      * Writes the specified binary or text data to a file
  37      * @param string The file path
  38      * @param mixed The data to be written
  39      * @param string The attributes for the write operation ('w' or 'wb')
  40      */
  41  	function putDataToFile($fileName, &$data, $writeAttributes) {
  42          $fileHandle = @fopen($fileName, $writeAttributes);
  43  
  44          if ($fileHandle) {
  45              fwrite($fileHandle, $data);
  46              fclose($fileHandle);
  47          }
  48      } //putDataToFile
  49  } //php_file_utilities
  50  ?>


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1