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 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php