[pLog-svn] r6274 - plog/branches/lifetype-1.2/class/misc
jondaley at devel.lifetype.net
jondaley at devel.lifetype.net
Sat Mar 29 12:48:40 EDT 2008
Author: jondaley
Date: 2008-03-29 12:48:39 -0400 (Sat, 29 Mar 2008)
New Revision: 6274
Modified:
plog/branches/lifetype-1.2/class/misc/glob.class.php
Log:
support FNM_CASEFOLD parameter of fnmatch. This might not work on windows at all, due to not having FNM_CASEFOLD defined? Please check and let me know if you get a PHP crash
Modified: plog/branches/lifetype-1.2/class/misc/glob.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/misc/glob.class.php 2008-03-28 19:29:47 UTC (rev 6273)
+++ plog/branches/lifetype-1.2/class/misc/glob.class.php 2008-03-29 16:48:39 UTC (rev 6274)
@@ -68,15 +68,15 @@
* @return True if the file matches the pattern or false if not.
* @static
*/
- function fnmatch( $pattern, $file )
+ function fnmatch( $pattern, $file, $flags = 0 )
{
if( function_exists("fnmatch")) {
// use the native fnmatch version
- return fnmatch( $pattern, $file );
+ return fnmatch( $pattern, $file, $flags );
}
else {
// otherwise, use our own
- return Glob::myFnmatch( $pattern, $file );
+ return Glob::myFnmatch( $pattern, $file, $flags );
}
}
@@ -91,7 +91,7 @@
* files will match and which will not.
* @return An array with the matching files and false if error.
*/
- function myGlob( $folder = ".", $pattern = "*" )
+ function myGlob( $folder = ".", $pattern = "*", $flags = 0 )
{
// Note that !== did not exist until 4.0.0-RC2
// what if the temp folder is deleted? or $folder is not exist? then will raise
@@ -103,7 +103,7 @@
while (false !== ($file = readdir($handle))) {
if( $file !="." && $file != ".." ) // ignore '.' and '..'
- if( Glob::fnmatch($pattern,$file)) {
+ if( Glob::fnmatch($pattern,$file,$flags)) {
if( $folder[strlen($folder)-1] != "/")
$filePath = $folder."/".$file;
else
@@ -129,12 +129,12 @@
*
* @static
*/
- function myFnmatch( $pattern, $file )
+ function myFnmatch( $pattern, $file, $flags = 0 )
{
for($i=0,$len = strlen($pattern); $i<$len; $i++) {
if($pattern[$i] == "*") {
for($c=$i; $c<max(strlen($pattern), strlen($file)); $c++) {
- if(Glob::myFnmatch(substr($pattern, $i+1), substr($file, $c))) {
+ if(Glob::myFnmatch(substr($pattern, $i+1), substr($file, $c), $flags)) {
return true;
}
}
@@ -150,7 +150,7 @@
break;
}
foreach ($letter_set as $letter) {
- if(Glob::myFnmatch($letter.substr($pattern, $c+1), substr($file, $i))) {
+ if(Glob::myFnmatch($letter.substr($pattern, $c+1), substr($file, $i), $flags)) {
return true;
}
}
@@ -159,11 +159,18 @@
if($pattern[$i] == "?") {
continue;
}
- if($pattern[$i] != $file[$i]) {
- return false;
- }
+ if($flags == FNM_CASEFOLD){
+ if(strtolower($pattern[$i]) != strtolower($file[$i])) {
+ return false;
+ }
+ }
+ else{
+ if($pattern[$i] != $file[$i]) {
+ return false;
+ }
+ }
}
return true;
- }
+ }
}
?>
More information about the pLog-svn
mailing list