chregu Fri Mar 23 10:35:17 2001 EDT Modified files: (Branch: PHP_4_0_5) /php4/pear/Cache/Container file.php Log: just the changes from the HEAD dev here. rather important Index: php4/pear/Cache/Container/file.php diff -u php4/pear/Cache/Container/file.php:1.8 php4/pear/Cache/Container/file.php:1.8.2.1 --- php4/pear/Cache/Container/file.php:1.8 Thu Mar 8 12:39:16 2001 +++ php4/pear/Cache/Container/file.php Fri Mar 23 10:35:17 2001 @@ -16,7 +16,7 @@ // | Sebastian Bergmann <[EMAIL PROTECTED]> | // +----------------------------------------------------------------------+ // -// $Id: file.php,v 1.8 2001/03/08 20:39:16 uw Exp $ +// $Id: file.php,v 1.8.2.1 2001/03/23 18:35:17 chregu Exp $ require_once 'Cache/Container.php'; @@ -24,29 +24,29 @@ * Stores cache contents in a file. * * @author Ulf Wendel <[EMAIL PROTECTED]> -* @version $Id: file.php,v 1.8 2001/03/08 20:39:16 uw Exp $ +* @version $Id: file.php,v 1.8.2.1 2001/03/23 18:35:17 chregu Exp $ */ class Cache_Container_file extends Cache_Container { /** * Directory where to put the cache files. - * + * * @var string Make sure to add a trailing slash */ var $cache_dir = ""; /** * Filename prefix for cache files. - * + * * You can use the filename prefix to implement a "domain" based cache or just - * to give the files a more descriptive name. The word "domain" is borroed from - * a user authentification system. One user id (cached dataset with the ID x) + * to give the files a more descriptive name. The word "domain" is borroed from + * a user authentification system. One user id (cached dataset with the ID x) * may exists in different domains (different filename prefix). You might want * to use this to have different cache values for a production, development and * quality assurance system. If you want the production cache not to be influenced * by the quality assurance activities, use different filename prefixes for them. - * - * I personally don't think that you'll never need this, but 640kb happend to be + * + * I personally don't think that you'll never need this, but 640kb happend to be * not enough, so... you know what I mean. If you find a useful application of the * feature please update this inline doc. * @@ -56,7 +56,7 @@ /** * Creates the cache directory if neccessary - * + * * @param array Config options: ["cache_dir" => ..., "filename_prefix" => ...] */ function Cache_Container_file($options = "") { @@ -65,6 +65,11 @@ clearstatcache(); + //make relative paths absolute for use in deconstructor. + // it looks like the deconstructor has problems with relative paths + if (preg_match("/\.+/",$this->cache_dir)) + $this->cache_dir=realpath(getcwd()."/".$this->cache_dir)."/"; + if (!file_exists($this->cache_dir) || !is_dir($this->cache_dir)) mkdir($this->cache_dir, 0755); } // end func contructor @@ -92,7 +97,7 @@ /** * Stores a dataset. - * + * * WARNING: If you supply userdata it must not contain any linebreaks, * otherwise it will break the filestructure. */ @@ -119,7 +124,7 @@ return true; } // end func save - + function delete($id, $group) { $this->flushPreload($id, $group); @@ -147,20 +152,20 @@ function idExists($id, $group) { return file_exists($this->getFilename($id, $group)); - + } // end func idExists /** * Deletes all expired files. - * + * * Garbage collection for files is a rather "expensive", "long time" - * operation. All files in the cache directory have to be examined which - * means that they must be opened for reading, the expiration date has to be + * operation. All files in the cache directory have to be examined which + * means that they must be opened for reading, the expiration date has to be * read from them and if neccessary they have to be unlinked (removed). * If you have a user comment for a good default gc probability please add it to * to the inline docs. - * - * @param string directory to examine - don't sets this parameter, it's used for a + * + * @param string directory to examine - don't sets this parameter, it's used +for a * recursive function call! */ function garbageCollection($dir = "") { @@ -177,8 +182,10 @@ continue; $file = $dir . $file; - if (is_dir($file)) + if (is_dir($file)) { $this->garbageCollection($file . "/"); + continue; + } // skip trouble makers but inform the user if (!($fh = @fopen($file, "rb"))) { @@ -186,7 +193,7 @@ continue; } - $expire = time(fgets($fh, 11)); + $expire = fgets($fh, 11); fclose($fh); // remove if expired @@ -227,7 +234,7 @@ /** * Deletes a directory and all files in it. - * + * * @param string directory * @return integer number of removed files * @throws Cache_Error -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]