<?
if( !defined( "FILEFUNCTIONS_H" ) ){
define( "FILEFUNCTIONS_H", "1" );
//$DESCRIPTION = "Will write, read, append, delete a file";
//$AUTHOR = "Magno Cardona Heck, hide@address.com";
//$NAME = "class file_manager";
class file_manager {
var $filename;
var $text;
function file_manager ($where_is_file) { //Construct the file_manager
$this->filename = $where_is_file;
}
//Open for writing only; place the file pointer
// at the beginning of the file and truncate the
//file to zero length. If the file does not exist,
//attempt to create it.
function write ($texto) {
$this->text = $texto;
$fp = fopen($this->filename, "w");
fwrite ($fp, $this->text);
fclose($fp);
}
//Open for reading only; place the file pointer at the beginning of the file.
function read () {
$fp = fopen($this->filename, "r");
$this->text = fread($fp, filesize("$this->filename"));
fclose($fp);
return $this->text;
}
//Open for writing only; place the file pointer at the end of the file.
//If the file does not exist, attempt to create it.
function append () {
$fp = fopen($this->filename, "a");
fwrite ($fp,$this->text);
fclose($fp);
}
//Delete a file
function delete () {
unlink ("$this->filename");
}
}
} //end of IFDEF
?>