Skip to content

Commit

Permalink
Making private properties and methods in FileEngine protected. Will m…
Browse files Browse the repository at this point in the history
…ake any possible subclasses easier to work with.
  • Loading branch information
markstory committed Feb 23, 2010
1 parent fbf054b commit 753721c
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions cake/libs/cache/file.php
Expand Up @@ -35,9 +35,9 @@ class FileEngine extends CacheEngine {
* Instance of File class
*
* @var File
* @access private
* @access protected
*/
var $__File = null;
var $_File = null;

/**
* Settings
Expand All @@ -57,9 +57,9 @@ class FileEngine extends CacheEngine {
* True unless FileEngine::__active(); fails
*
* @var boolean
* @access private
* @access protected
*/
var $__init = true;
var $_init = true;

/**
* Initialize the Cache Engine
Expand All @@ -79,15 +79,15 @@ function init($settings = array()) {
),
$settings
));
if (!isset($this->__File)) {
$this->__File =& new File($this->settings['path'] . DS . 'cake');
if (!isset($this->_File)) {
$this->_File =& new File($this->settings['path'] . DS . 'cake');
}

if (DIRECTORY_SEPARATOR === '\\') {
$this->settings['isWindows'] = true;
}

$path = $this->__File->Folder->cd($this->settings['path']);
$path = $this->_File->Folder->cd($this->settings['path']);
if ($path) {
$this->settings['path'] = $path;
}
Expand All @@ -114,11 +114,11 @@ function gc() {
* @access public
*/
function write($key, &$data, $duration) {
if ($data === '' || !$this->__init) {
if ($data === '' || !$this->_init) {
return false;
}

if ($this->__setKey($key) === false) {
if ($this->_setKey($key) === false) {
return false;
}

Expand All @@ -137,12 +137,12 @@ function write($key, &$data, $duration) {
}

if ($this->settings['lock']) {
$this->__File->lock = true;
$this->_File->lock = true;
}
$expires = time() + $duration;
$contents = $expires . $lineBreak . $data . $lineBreak;
$success = $this->__File->write($contents);
$this->__File->close();
$success = $this->_File->write($contents);
$this->_File->close();
return $success;
}

Expand All @@ -154,28 +154,28 @@ function write($key, &$data, $duration) {
* @access public
*/
function read($key) {
if ($this->__setKey($key) === false || !$this->__init || !$this->__File->exists()) {
if ($this->_setKey($key) === false || !$this->_init || !$this->_File->exists()) {
return false;
}
if ($this->settings['lock']) {
$this->__File->lock = true;
$this->_File->lock = true;
}
$time = time();
$cachetime = intval($this->__File->read(11));
$cachetime = intval($this->_File->read(11));

if ($cachetime !== false && ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime)) {
$this->__File->close();
$this->_File->close();
return false;
}
$data = $this->__File->read(true);
$data = $this->_File->read(true);

if ($data !== '' && !empty($this->settings['serialize'])) {
if ($this->settings['isWindows']) {
$data = str_replace('\\\\\\\\', '\\', $data);
}
$data = unserialize((string)$data);
}
$this->__File->close();
$this->_File->close();
return $data;
}

Expand All @@ -187,10 +187,10 @@ function read($key) {
* @access public
*/
function delete($key) {
if ($this->__setKey($key) === false || !$this->__init) {
if ($this->_setKey($key) === false || !$this->_init) {
return false;
}
return $this->__File->delete();
return $this->_File->delete();
}

/**
Expand All @@ -201,7 +201,7 @@ function delete($key) {
* @access public
*/
function clear($check) {
if (!$this->__init) {
if (!$this->_init) {
return false;
}
$dir = dir($this->settings['path']);
Expand All @@ -210,24 +210,24 @@ function clear($check) {
$threshold = $now - $this->settings['duration'];
}
while (($entry = $dir->read()) !== false) {
if ($this->__setKey($entry) === false) {
if ($this->_setKey($entry) === false) {
continue;
}
if ($check) {
$mtime = $this->__File->lastChange();
$mtime = $this->_File->lastChange();

if ($mtime === false || $mtime > $threshold) {
continue;
}

$expires = $this->__File->read(11);
$this->__File->close();
$expires = $this->_File->read(11);
$this->_File->close();

if ($expires > $now) {
continue;
}
}
$this->__File->delete();
$this->_File->delete();
}
$dir->close();
return true;
Expand All @@ -240,13 +240,13 @@ function clear($check) {
* @return mixed Absolute cache file for the given key or false if erroneous
* @access private
*/
function __setKey($key) {
$this->__File->Folder->cd($this->settings['path']);
if ($key !== $this->__File->name) {
$this->__File->name = $key;
$this->__File->path = null;
function _setKey($key) {
$this->_File->Folder->cd($this->settings['path']);
if ($key !== $this->_File->name) {
$this->_File->name = $key;
$this->_File->path = null;
}
if (!$this->__File->Folder->inPath($this->__File->pwd(), true)) {
if (!$this->_File->Folder->inPath($this->_File->pwd(), true)) {
return false;
}
}
Expand All @@ -258,8 +258,8 @@ function __setKey($key) {
* @access private
*/
function __active() {
if ($this->__init && !is_writable($this->settings['path'])) {
$this->__init = false;
if ($this->_init && !is_writable($this->settings['path'])) {
$this->_init = false;
trigger_error(sprintf(__('%s is not writable', true), $this->settings['path']), E_USER_WARNING);
}
return true;
Expand Down

0 comments on commit 753721c

Please sign in to comment.