As I mentioned in an earlier method it is nice to be able to control
order of traversal. For example if you want to delete all files
(perhaps as the implementation of deleteRecurse method) you want to
traverse Postorder instead of Preorder.
Just a consideration. Would there be a way to do this?
A lessor issue is how would files within a directory be sorted (for traversal).
Thanks for the thoughts,
Jesse
On Mon, Jun 22, 2009 at 8:47 AM, Jorge Ortiz<
jorge.ortiz@...> wrote:
> I'd encourage the use of strings rather than operators for this. Operators
> look cute, but for something like this would prove a little too brittle, I'm
> afraid.
>
> --j
>
> On Sun, Jun 21, 2009 at 12:14 PM, Josh Suereth <
joshua.suereth@...>
> wrote:
>>
>> Not a bad idea. The .g would have to be after the directory in which to
>> search. Paulp also suggested just using the existing regularExpression.
>>
>> So....
>>
>> for {
>> file <- pwd / "**/*.log".r
>> ...
>>
>>
>> or
>>
>>
>> for {
>> file <- pwd / "**/*.log".g
>> ...
>>
>>
>>
>> I'm thinking .g might actually be required so we can specially handle the
>> ** as "in any subdirectory". If we used pure regular expressions, it would
>> confuse those who expected glob-mapping. Perhaps a combined approach that
>> would allow either?
>>
>>
>> - Josh
>>
>> On Sun, Jun 21, 2009 at 3:10 PM, Alex Boisvert <
boisvert@...>
>> wrote:
>>>
>>> Another idea would be to define a pimp conversion "globExpression".g
>>> analogous to the standard "regularExpression".r
>>>
>>> for {
>>> file <- (pwd + "/**/*.log").g
>>> lines <- file.readLines
>>> if line startsWith "[ERROR]"
>>> } yield line
>>>
>>> The ** and * globs are easy to masquerade into the syntax but what about
>>> things like .{c, cpp, java} ?
>>>
>>> for {
>>> file <- (pwd + "/**/*.{java,scala}").g
>>> lines <- file.readLines
>>> if line startsWith "[ERROR]"
>>> } yield line
>>>
>>> alex
>>>
>>> On Sun, Jun 21, 2009 at 11:21 AM, Josh Suereth <
joshua.suereth@...>
>>> wrote:
>>>>
>>>> Wanted to get people's thoughts on glob-mapping of files using the
>>>> File-Tree-Walker style interface. (This is an idea I got from SBT)
>>>>
>>>>
>>>> Imagine the following code:
>>>>
>>>> for {
>>>> file <- pwd / ** / "*.log" //The spaces are necessary so we don't
>>>> make a comment!
>>>> lines <- file.readLines
>>>> if line startsWith "[ERROR]"
>>>> } yield line
>>>>
>>>> for pulling out all lines from all log files under the current working
>>>> directory or any sub-directory.
>>>>
>>>>
>>>> Another example:
>>>>
>>>> for {
>>>> file <- pwd / * ".log"
>>>> lines <- file.readLines
>>>> if line startsWith "[ERROR]"
>>>> } yield line
>>>>
>>>>
>>>> This would do something similar to the above but only for one directory.
>>>>
>>>>
>>>> I'm not exactly happy with the operators used, but I do like the
>>>> idea. Any thoughts?
>>>>
>>>>
>>>> - Josh
>>>
>>
>
>