From: Garance A Drosihn Date: 2002-01-24T12:45:28+09:00 Subject: Re: Minor thoughts on 'Find' module At 5:56 AM +0900 1/24/02, Michael Witrant wrote: >On Wed, 23 Jan, matz@ruby-lang.org (Yukihiro Matsumoto) wrote: > > > Could you propose the possible API of the "new Find"? I am new to ruby, so I am not sure what the most-natural API would be. Something like the following sounds okay to me, although I do not think there should be a default setting for 'root'. I think the programmer should explicitly specify the root, even if it is just ".". I believe that is how the current Find.find works, and it seems right to me. >What about Find.find(root = '.', *options)? > >Options could be symbols or hashes. Each symbol is converted to a >hash like { :symbol => true }. Options are then flattened and >converted to a unique hash. Some options could be compatible, >some not. The current Find allows for multiple directory names to be given on the call to Find.find. I do not know if the above does. (As I said, I am still pretty new to ruby... :-). >Possible options: > :files_first > :directories_first > :depth_first > :files_only > :directories_only > :match => regexp > :follow_symlinks > :max_depth => integer > :without_root # this one would delete the provided root > # from the returned/yielded file names > ... >And why not all those wonderfull options find(1) provides? I would suggest options of 'directories_first' and 'directories_last', because that avoids the question of how things like symlinks, sockets, or named-pipes would be treated under "files_first". Similarly, I would suggest "directories_only" and "no_directories" (unless "files_only" really means only files, and it would not send to the block any names which are symlinks, sockets, or named-pipes). I do not think "match" makes sense. That can just as easily be done within the code-block that the caller specifies. It seems like more overhead to pass the pattern into Find for Find to process, than it would be for the code-block to do the same processing. >Also, without block given, it should return an array of those files. This sounds reasonable to me, although I am not sure that I would use it much. - - - Let me think about this some more. The more I think about it, the more I think I want to make a significantly different suggestion. I have not figured out all the details of what I want to suggest. -- Garance Alistair Drosehn = gad@eclipse.acs.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu