Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:28161 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80104 invoked by uid 1010); 26 Feb 2007 22:29:50 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 80089 invoked from network); 26 Feb 2007 22:29:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Feb 2007 22:29:50 -0000 Authentication-Results: pb1.pair.com header.from=helly@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=helly@php.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain php.net from 85.214.94.56 cause and error) X-PHP-List-Original-Sender: helly@php.net X-Host-Fingerprint: 85.214.94.56 aixcept.net Received: from [85.214.94.56] ([85.214.94.56:54274] helo=h1149922.serverkompetenz.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BE/40-09863-B5F53E54 for ; Mon, 26 Feb 2007 17:29:49 -0500 Received: from [192.168.1.3] (dslb-084-063-015-201.pools.arcor-ip.net [84.63.15.201]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by h1149922.serverkompetenz.net (Postfix) with ESMTP id 1094D1B3639; Mon, 26 Feb 2007 23:29:45 +0100 (CET) Date: Mon, 26 Feb 2007 23:29:44 +0100 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <1331353216.20070226232944@marcus-boerger.de> To: Arnold Daniels CC: helly@php.net, internals@lists.php.net In-Reply-To: <45E33990.8030806@adaniels.nl> References: <45E33990.8030806@adaniels.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] suggestion SplFileInfo From: helly@php.net (Marcus Boerger) Hello Arnold, some interesting ideas indeed. See my comments below. best regards marcus Monday, February 26, 2007, 8:48:32 PM, you wrote: > Hi, > I've got a few feature suggestions for SplFileInfo and > DirectoryIteratorRecursive. I'm creating yet another php file manager. > I've noticed that I needed to add quite some code to make it act the way > gnome nautilus does. I believe these feature would be a good addition. > SplFileInfo: > - Add parameter $flags to constructor. The flags are passed to any > fileinfo object created. In case we need flags this will be added to the constructor or as seperate getter/setter. My preference is actually the latter. > - Add flags FOLLOW_LINK_ALWAYS, FOLLOW_LINK_EXISTS, FOLLOW_LINK_NEVER > for the constructor. Functions as getPerms and getOwner will look at > this setting. I will need to check whether I Can do that. If so I will add flags as well. Until then you can overwrite hasChildren() to return "parent::hasChildren() && !this->isLink()" to solve the third flag. The second flag also needs to verify the target by using getLinkTarget() (see below). Finally the first flag is simplywhat we have right now. > - Add getBasename, to get the basename of either a dir or file. > - Function getLinkTarget, does readlink($this->getPathname()) added in HEAD as getLinkTarget() > - Function getRealpath, does realpath($this->getPathname()) added in HEAD as getRealPath() > - Function getOwnerName and getGroupName Use posix_getpwuid() and posix_getgrgid() *if available*. I prefer not to have them in SPL. > - Function isHidden, to check wether a file is hidden I don't think we have support for windows' hidden flag, do we? Under *nix as I just reminded you can simply check whether thefilename starts with a dot. > - Functions getTypeInfo and getMime, to get info of the file using libmagic there are getType and getMTime, that should be enough no? > - Function setDirInfoClass, set a info class specially for directories What I could do is providing a slow mechanism that actually does a stat call and checks the dir flag. Then internally add a pointer for the directory info class and a getter/setter for that. It would be initialized to null and thegetter would see the normal info class as long as it is null. That way the directory info is bound to the standard info class until you explicitly split it. Would this solve your problem? Maybe for PHP 5.3 there should be a stat cache tospeeed things up. > DirectoryIteratorRecursive: > - Add flag DIRS_ONLY for the constructor, to only loop through directories This is achieved by a FilterIterator: ParentIterator > - Add flag WITHOUT_HIDDEN_FILES for the constructor, not to loop > through hidden files Can be done easily by providing a filter. > - Function getFileCount That would require to loop through the directory which is not what we want. If you need the count after usingthe elements you can for example loop through a CachingIterator which ha sa newly introduced count method that will give you the number of elements used. > If you like these features, but don't have time to implement them, I can > see if I can write a patch. I'm quite new at writing PHP extensions, but > I know the basics. > Best regards, > Arnolds Best regards, Marcus