Fixing cache setting when installing a fresh version on a Win box

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5078 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mariano.iglesias 2007-05-13 21:54:48 +00:00
parent 338a8c8f4b
commit 4aa29a073d

View file

@ -25,6 +25,13 @@
* @lastmodified $Date$ * @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License * @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/ */
/**
* Included libraries.
*
*/
if (!class_exists('Folder')) {
uses ('folder');
}
/** /**
* File Storage engine for cache * File Storage engine for cache
* *
@ -34,21 +41,21 @@
*/ */
class FileEngine extends CacheEngine { class FileEngine extends CacheEngine {
/** /**
* Enter description here... * Cache directory
* *
* @var unknown_type * @var string
*/ */
var $_dir = ''; var $_dir = '';
/** /**
* Enter description here... * Cache filename prefix
* *
* @var unknown_type * @var string
*/ */
var $_prefix = ''; var $_prefix = '';
/** /**
* Enter description here... * Use locking
* *
* @var unknown_type * @var boolean
*/ */
var $_lock = false; var $_lock = false;
/** /**
@ -65,22 +72,16 @@ class FileEngine extends CacheEngine {
$lock = false; $lock = false;
extract($params); extract($params);
$dir = trim($dir); $dir = trim($dir);
$folder =& new Folder();
if(strlen($dir) < 1) { if (!empty($dir)) {
$dir = $folder->slashTerm($dir);
}
if(empty($dir) || !$folder->isAbsolute($dir) || !is_writable($dir)) {
return false; return false;
} }
if($dir{0} != DS) {
return false;
}
if(!is_writable($dir)) {
return false;
}
if($dir{strlen($dir)-1} != DS) {
$dir .= DS;
}
$this->_dir = $dir; $this->_dir = $dir;
$this->_prefix = strval($prefix); $this->_prefix = strval($prefix);
$this->_lock = $lock; $this->_lock = $lock;
@ -90,7 +91,7 @@ class FileEngine extends CacheEngine {
* Garbage collection * Garbage collection
* Permanently remove all expired and deleted data * Permanently remove all expired and deleted data
* *
* @return boolean * @return boolean True if garbage collection was succesful, false on failure
*/ */
function gc() { function gc() {
return $this->clear(true); return $this->clear(true);
@ -124,10 +125,10 @@ class FileEngine extends CacheEngine {
/** /**
* write serialized data to a file * write serialized data to a file
* *
* @param unknown_type $filename * @param string $filename
* @param unknown_type $value * @param string $value
* @param unknown_type $expires * @param integer $expires
* @return unknown * @return boolean True on success, false on failure
*/ */
function _writeCache(&$filename, &$value, &$expires) { function _writeCache(&$filename, &$value, &$expires) {
$contents = $expires."\n".$value."\n"; $contents = $expires."\n".$value."\n";
@ -172,8 +173,8 @@ class FileEngine extends CacheEngine {
/** /**
* Get the expiry time for a cache file * Get the expiry time for a cache file
* *
* @param unknown_type $filename * @param string $filename
* @return unknown * @return mixed Expiration timestamp, or false on failure
*/ */
function _getExpiry($filename) { function _getExpiry($filename) {
$fp = fopen($filename, 'r'); $fp = fopen($filename, 'r');