mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
a8eed860b2
- added a new class, File, currently only used by the Log class and Compressed CSS (CCSS) caching; aims to support easy reading and writing of files git-svn-id: https://svn.cakephp.org/repo/trunk/cake@252 3807eeeb-6ff5-0310-8944-8be069107fe0
40 lines
No EOL
540 B
PHP
40 lines
No EOL
540 B
PHP
<?php // $Id$
|
|
|
|
class File
|
|
{
|
|
var $path = null;
|
|
|
|
function File ($path)
|
|
{
|
|
$this->path = $path;
|
|
}
|
|
|
|
function read ()
|
|
{
|
|
return file_get_contents($this->path);
|
|
}
|
|
|
|
function append ($data)
|
|
{
|
|
return $this->write($data, 'a');
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
?>
|