<?php
// Xinfeng Chen, 2002.11.06
class CBaseMemoFile {

 function _explodeRecord($a_line){}
 // Implemeted by descendant, Return: NONE
 function _composeRecord($a_line){}
 // Implemeted by descendant, Return composed line as $a_line

 function reset(){ $this->_explodeRecord(''); }

 function readFile($a_filename){
  $buffer='';
  if(file_exists($a_filename)){
   $lines=@file($a_filename);
   if(count($lines)>0) { $buffer=chop($lines[0]); }
  }
  $this->_explodeRecord(&$buffer);
  return isset($lines);
 }

 function writeFile($a_filename){
  $buffer='';
  $this->_composeRecord(&$buffer);

  if(!($TMP=fopen($a_filename,"w"))){return false;}
  fwrite($TMP,$buffer);
  fclose($TMP); chmod($a_filename, 0660);
  return true;
 }

 function createFile($a_filename){ $this->reset(); return true; }

 function destroyFile($a_filename){
  if(!is_file($a_filename)){return false;}
  return unlink($a_filename);
 }

}
?>