Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:28164 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13287 invoked by uid 1010); 27 Feb 2007 00:36:26 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 13272 invoked from network); 27 Feb 2007 00:36:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Feb 2007 00:36:26 -0000 Authentication-Results: pb1.pair.com header.from=info@adaniels.nl; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=info@adaniels.nl; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain adaniels.nl from 82.94.236.173 cause and error) X-PHP-List-Original-Sender: info@adaniels.nl X-Host-Fingerprint: 82.94.236.173 loco.helderhosting.nl Linux 2.5 (sometimes 2.4) (4) Received: from [82.94.236.173] ([82.94.236.173:35126] helo=loco.helderhosting.nl) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1D/A3-09863-80D73E54 for ; Mon, 26 Feb 2007 19:36:26 -0500 Received: from [192.168.1.174] (a80-126-54-132.adsl.xs4all.nl [80.126.54.132]) by loco (Postfix) with ESMTP id 86D9F10D8AF1; Tue, 27 Feb 2007 01:36:21 +0100 (CET) Message-ID: <45E37D05.5040000@adaniels.nl> Date: Tue, 27 Feb 2007 01:36:21 +0100 User-Agent: Thunderbird 1.5.0.9 (X11/20070103) MIME-Version: 1.0 To: Marcus Boerger Cc: internals@lists.php.net References: <45E33990.8030806@adaniels.nl> <1331353216.20070226232944@marcus-boerger.de> In-Reply-To: <1331353216.20070226232944@marcus-boerger.de> Content-Type: multipart/alternative; boundary="------------080505040901090600010705" Subject: Re: [PHP-DEV] suggestion SplFileInfo From: info@adaniels.nl (Arnold Daniels) --------------080505040901090600010705 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hi again, Thanks for your response. I've put some new comments below. Marcus Boerger wrote: > 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. > Sure that works just as well, but it would be useful if the flags are passed down. That way you can also use it on a DirectoryIterator. > >> - 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 I believe that there is a bit of miscommunication here. The flags should determine if stat or lstat is used to get the properties of the files. Currently spl always uses stat. Perhaps the names I came up with aren't perfect. > . > > >> - Add getBasename, to get the basename of either a dir or file. >> Did you overlook this? or don't you like it. >> - Function getLinkTarget, does readlink($this->getPathname()) >> > added in HEAD as getLinkTarget() > Perfect > >> - Function getRealpath, does realpath($this->getPathname()) >> > added in HEAD as getRealPath() > Excellent > >> - Function getOwnerName and getGroupName >> > Use posix_getpwuid() and posix_getgrgid() *if available*. I prefer not to > have them in SPL. > Ok very well > >> - 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. > Yes that true, but it would be nice to have a function which returns a boolean and work for both windows and unix. Perhaps a workaround can be thought off for windows. > >> - Functions getTypeInfo and getMime, to get info of the file using libmagic >> > there are getType and getMTime, that should be enough no? > No the name are almost the same, but the output isn't. I'm talking about integrating the features provided by fileinfo (http://www.php.net/fileinfo). Perhaps the names aren't chosen well. > >> - 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. > Yes that would be perfect. PS. Currently looping with a DirectoryIterator returns a DirectoryIterator for each child, dirs as well as files, instead of the class set using setInfoClass(). Is this correct? It wasn't what I expected. RecursiveDirectoryIterator work like I expected. > >> DirectoryIteratorRecursive: >> - Add flag DIRS_ONLY for the constructor, to only loop through directories >> > This is achieved by a FilterIterator: ParentIterator > Yes but if you want to loop recursively through the directories, creating an object for each file gives a huge overhead. Glob has a directory only flag, may that feature can be used. > >> - Add flag WITHOUT_HIDDEN_FILES for the constructor, not to loop >> through hidden files >> > Can be done easily by providing a filter. > Ok that is fine. > >> - 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. > Isn't there a way you can easily get this information from the system? Anyhow I much rather have a loop in c through a set of filenames, than looping in php using the iterator. I believe having the ability to give the number of files of a directory is really useful, even if you don't want to do anything with the files from the dir. For example: gnome nautilus displays the number files for each dir instead of the filesize. > >> 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. >> Thanks again. If you need any help, please let me know. Best regards, Arnold --------------080505040901090600010705--