[Phpslash-commit] CVS: phpslash-dev/include/class/jpcache/type file.php,1.2,1.3
Brought to you by:
joestewart,
nhruby
From: Luis M <le...@us...> - 2004-10-20 22:07:04
|
Update of /cvsroot/phpslash/phpslash-dev/include/class/jpcache/type In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23609 Modified Files: file.php Log Message: fixed to avoid ugly warnings from php when dir doesn't exist Index: file.php =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/include/class/jpcache/type/file.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** file.php 11 Sep 2004 14:45:24 -0000 1.2 --- file.php 20 Oct 2004 22:06:53 -0000 1.3 *************** *** 96,103 **** function jpcache_do_gc($method='cachetimeout', $argv='') { switch($method) { case 'regex': - $dp=opendir($GLOBALS["JPCACHE_DIR"]); --- 96,104 ---- function jpcache_do_gc($method='cachetimeout', $argv='') { + //if ( psl_jpcache_test_dir() ) { + psl_jpcache_test_dir(); // FIXME test this now. later we should throw an exception switch($method) { case 'regex': $dp=opendir($GLOBALS["JPCACHE_DIR"]); *************** *** 134,138 **** case 'string': - $dp=opendir($GLOBALS["JPCACHE_DIR"]); --- 135,138 ---- *************** *** 170,174 **** case 'cachetimeout': default: - $dp=opendir($GLOBALS["JPCACHE_DIR"]); --- 170,173 ---- *************** *** 224,242 **** function jpcache_do_start() { ! if ( ! is_dir( $GLOBALS["JPCACHE_DIR"] ) ) ! { ! /* Attempt to create the JPCACHE_DIR ! * Note that this won't recursively make ! * the necessary directories to reach this path ! * (as would the UNIX command "mkdir -p"). ! * This functionality was added in PHP 5. ! * TODO check if we are running php5 and call: ! * mkdir($GLOBALS["JPCACHE_DIR"],0700,true). ! * This way all directories prior to the directory ! * we are making will be created as well. ! * Else we should fall back to php4's way. ! */ ! mkdir($GLOBALS["JPCACHE_DIR"],0700); ! } } --- 223,227 ---- function jpcache_do_start() { ! psl_jpcache_test_dir(); } *************** *** 309,311 **** --- 294,323 ---- // Make sure no additional lines/characters are after the closing-tag! + + /** Tests for Cache dir + * internal function + */ + function psl_jpcache_test_dir() { + if ( is_dir( $GLOBALS["JPCACHE_DIR"] ) ) + { + return true; + } else { + /* Attempt to create the JPCACHE_DIR + * Note that this won't recursively make + * the necessary directories to reach this path + * (as would the UNIX command "mkdir -p"). + * This functionality was added in PHP 5. + * TODO check if we are running php5 and call: + * mkdir($GLOBALS["JPCACHE_DIR"],0700,true). + * This way all directories prior to the directory + * we are making will be created as well. + * Else we should fall back to php4's way. + */ + if ( mkdir($GLOBALS["JPCACHE_DIR"],0700) ) { + return true; + } else { + return false; + } + } + } // end psl_jpcache_test_dir() ?> |