On 10-12-20 11:56 PM, Bryan Tong Minh wrote:
> On Tue, Dec 21, 2010 at 5:21 AM, Soxred93<[email protected]>  wrote:
>> The usage is simple:
>> sfFinder::type('file')->name('*.php')->in('/path/to/dir'); //list of PHP 
>> files in directory and all subdirectories
>> sfFinder::type('file')->name('*.php')->in('/path/to/dir')->recurse(0); 
>> //list of PHP files in that directory only
>> sfFinder::type('dir')->name('foo')->in('/path/to/dir'); //list of 
>> directories with the name "foo"
>> There is documentation at [3], but it's for an old version. The code is very 
>> similar though, so most of it should apply to the current version.
>>
> I personally dislike the chained syntax. A file system abstraction
> layer would be a good idea, but I believe the standard MediaWiki
> convention of passing arrays around rather than function chaining is
> much more elegant.
>
> Finder::openFile( 'filename' );
> Finder::findFile('7path', array( 'name'  =>  '*.php'))->delete();
> for ( Finder::findFiles($IP) as $file ) { $file->delete(); }
*twitch*
Yea, I don't mind chained syntax, I've moved on to JavaScript after 
all... but that api looks horrid to me...
There should be a clear distinction between safe names, and things where 
fnmatch patterns are interpreted.
Ruby gave me nothing but trouble in that regard... And it's a really bad 
idea to have to go and do complex wildcard matching and recursion for 
something that's really simple doesn't need wildcard matching or 
recursion and would actually end up with unexpected bugs if the name it 
passed was interpreted.

foreach ( Finder::openDirectory($wgStyleDirectory, array( 'type' => 
'directory' )) as $dir ) {
   $file = $dir->file($dir->name() . '.php');
   if ( $file->isReadable ) {
     require_once( $file->path() );
   } else {
     $skFile = $dir->findFile("*.skin.php");
     if ( $skFile->isReadable ) {
       $skinName = $skFile->basename("skin.php");
       $wgValidSkinNames[$dir->name()] = $skinName;
       $wgAutoloadClasses["Skin".$skinName] = $skFile->path;
     }
   }
}

Finder::findFiles($wgFileCacheDirectory, array( 'pattern' => '*.html' 
))->delete();

-- 
~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]


_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to