cvs: php4 /pear/Cache/Container file.php
| From: | Christian Stocker | Date: | Tue, 10 Jul 2001 14:38:57 +0000 |
| Subject: | cvs: php4 /pear/Cache/Container file.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-252@lists.php.net to get a copy of this message | ||
chregu Tue Jul 10 10:38:57 2001 EDT
Modified files:
/php4/pear/Cache/Container file.php
Log:
patch suggested by yavor
makes more sanity checks on cache_dir
Index: php4/pear/Cache/Container/file.php
diff -u php4/pear/Cache/Container/file.php:1.14 php4/pear/Cache/Container/file.php:1.15
--- php4/pear/Cache/Container/file.php:1.14 Sat Jul 7 19:15:16 2001
+++ php4/pear/Cache/Container/file.php Tue Jul 10 10:38:57 2001
@@ -16,7 +16,7 @@
// | Sebastian Bergmann <sb@sebastian-bergmann.de> |
// +----------------------------------------------------------------------+
//
-// $Id: file.php,v 1.14 2001/07/07 23:15:16 sbergmann Exp $
+// $Id: file.php,v 1.15 2001/07/10 14:38:57 chregu Exp $
require_once 'Cache/Container.php';
@@ -24,7 +24,7 @@
* Stores cache contents in a file.
*
* @author Ulf Wendel <ulf.wendel@phpdoc.de>
-* @version $Id: file.php,v 1.14 2001/07/07 23:15:16 sbergmann Exp $
+* @version $Id: file.php,v 1.15 2001/07/10 14:38:57 chregu Exp $
*/
class Cache_Container_file extends Cache_Container {
@@ -74,20 +74,25 @@
*
* @param array Config options: ["cache_dir" => ...,
"filename_prefix" => ...]
*/
- function Cache_Container_file($options = '') {
+ function Cache_Container_file($options = '') {
if (is_array($options))
$this->setOptions($options, array_merge($this->allowed_options,
array('cache_dir', 'filename_prefix')));
clearstatcache();
-
- // make relative paths absolute for use in deconstructor.
- // it looks like the deconstructor has problems with relative paths
- if ('.' == $this->cache_dir{0})
- $this->cache_dir = realpath( getcwd() . '/' . $this->cache_dir) .
'/';
-
- if (!file_exists($this->cache_dir) || !is_dir($this->cache_dir))
- mkdir($this->cache_dir, 0755);
-
+ if ($this->cache_dir)
+ {
+ // make relative paths absolute for use in deconstructor.
+ // it looks like the deconstructor has problems with relative paths
+ if ('/' != $this->cache_dir{0} )
+ $this->cache_dir = realpath( getcwd() . '/' . $this->cache_dir) .
'/';
+
+ // check if a trailing slash is in cache_dir
+ if (!substr($this->cache_dir,-1) )
+ $this->cache_dir .= '/';
+
+ if (!file_exists($this->cache_dir) || !is_dir($this->cache_dir))
+ mkdir($this->cache_dir, 0755);
+ }
$this->entries = array();
} // end func contructor