00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 require_once 'creole/util/Lob.php';
00023
00031 class Clob extends Lob {
00032
00040 public function readFromFile($file = null)
00041 {
00042 if ($file !== null) {
00043 $this->setInputFile($file);
00044 }
00045 if (!$this->inFile) {
00046 throw Exception('No file specified for read.');
00047 }
00048 $data = null;
00049 $file = fopen($this->inFile, "rt");
00050 while (!feof($file)) $data .= fgets($file, 4096);
00051 fclose($file);
00052 if ($data === false) {
00053 throw new Exception('Unable to read from file: '.$this->inFile);
00054 }
00055 $this->setContents($data);
00056 }
00057
00058
00065 public function writeToFile($file = null)
00066 {
00067 if ($file !== null) {
00068 $this->setOutputFile($file);
00069 }
00070 if (!$this->outFile) {
00071 throw new Exception('No file specified for write');
00072 }
00073 if ($this->data === null) {
00074 throw new Exception('No data to write to file');
00075 }
00076 $file = fopen($this->inFile, "wt");
00077 if (fputs($file, $this->data) === false)
00078 throw new Exception('Unable to write to file: '.$this->outFile);
00079 fclose($file);
00080 }
00081
00088 function dump()
00089 {
00090 if (!$this->data) {
00091
00092
00093 if ($this->inFile) {
00094 $fp = @fopen($this->inFile, "r");
00095 if (!$fp) {
00096 throw new Exception('Unable to open file: '.$this->inFile);
00097 }
00098 fpassthru($fp);
00099 @fclose($fp);
00100 } else {
00101 throw new Exception('No data to dump');
00102 }
00103
00104 } else {
00105 echo $this->data;
00106 }
00107
00108 }
00109
00110
00111
00112 }