2005-07-04 04:16:20 +00:00
|
|
|
<?php
|
2005-08-21 06:49:02 +00:00
|
|
|
/* SVN FILE: $Id$ */
|
2005-06-19 03:35:19 +00:00
|
|
|
|
2005-07-04 04:16:20 +00:00
|
|
|
/**
|
2005-08-21 06:49:02 +00:00
|
|
|
* Short description for file.
|
2005-07-04 04:16:20 +00:00
|
|
|
*
|
2005-08-21 06:49:02 +00:00
|
|
|
* Long description for file
|
|
|
|
*
|
|
|
|
* PHP versions 4 and 5
|
|
|
|
*
|
|
|
|
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
|
|
|
* Copyright (c) 2005, CakePHP Authors/Developers
|
|
|
|
*
|
|
|
|
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
|
|
|
|
* Larry E. Masters aka PhpNut <nut@phpnut.com>
|
|
|
|
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
2005-07-04 04:16:20 +00:00
|
|
|
* @filesource
|
2005-08-21 06:49:02 +00:00
|
|
|
* @author CakePHP Authors/Developers
|
|
|
|
* @copyright Copyright (c) 2005, CakePHP Authors/Developers
|
|
|
|
* @link https://trac.cakephp.org/wiki/Authors Authors/Developers
|
|
|
|
* @package cake
|
|
|
|
* @subpackage cake.libs
|
|
|
|
* @since CakePHP v 0.2.9
|
|
|
|
* @version $Revision$
|
|
|
|
* @modifiedby $LastChangedBy$
|
2005-07-10 05:08:19 +00:00
|
|
|
* @lastmodified $Date$
|
2005-08-21 06:49:02 +00:00
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
2005-07-04 04:16:20 +00:00
|
|
|
*/
|
|
|
|
|
2005-08-21 06:49:02 +00:00
|
|
|
|
2005-07-04 04:16:20 +00:00
|
|
|
/**
|
2005-08-21 06:49:02 +00:00
|
|
|
* Short description for class
|
|
|
|
*
|
|
|
|
* Long description for class
|
2005-07-04 04:16:20 +00:00
|
|
|
*
|
2005-08-21 06:49:02 +00:00
|
|
|
* @package cake
|
2005-07-04 04:16:20 +00:00
|
|
|
* @subpackage cake.libs
|
2005-08-21 06:49:02 +00:00
|
|
|
* @since CakePHP v 0.2.9
|
2005-07-04 04:16:20 +00:00
|
|
|
*/
|
2005-06-19 03:35:19 +00:00
|
|
|
class File
|
|
|
|
{
|
2005-07-04 04:16:20 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var unknown_type
|
|
|
|
*/
|
2005-07-10 05:08:19 +00:00
|
|
|
var $path = null;
|
|
|
|
|
2005-07-04 04:16:20 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @param unknown_type $path
|
|
|
|
* @return File
|
|
|
|
*/
|
2005-07-10 05:08:19 +00:00
|
|
|
function File ($path)
|
|
|
|
{
|
|
|
|
$this->path = $path;
|
|
|
|
}
|
|
|
|
|
2005-07-04 04:16:20 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @return unknown
|
|
|
|
*/
|
2005-07-10 05:08:19 +00:00
|
|
|
function read ()
|
|
|
|
{
|
|
|
|
return file_get_contents($this->path);
|
|
|
|
}
|
|
|
|
|
2005-07-04 04:16:20 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @param unknown_type $data
|
|
|
|
* @return unknown
|
|
|
|
*/
|
2005-07-10 05:08:19 +00:00
|
|
|
function append ($data)
|
|
|
|
{
|
|
|
|
return $this->write($data, 'a');
|
|
|
|
}
|
|
|
|
|
2005-07-04 04:16:20 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @param unknown_type $data
|
|
|
|
* @param unknown_type $mode
|
|
|
|
* @return unknown
|
|
|
|
*/
|
2005-07-10 05:08:19 +00:00
|
|
|
function write ($data, $mode = 'w')
|
|
|
|
{
|
|
|
|
if (!($handle = fopen($this->path, $mode)))
|
|
|
|
{
|
|
|
|
print ("[File] Could not open {$this->path} with mode $mode!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!fwrite($handle, $data))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!fclose($handle))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2005-06-19 03:35:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|