Talk:Walk a directory/Recursively: Difference between revisions

From Rosetta Code
Content added Content deleted
(response to over-restriction of task description)
No edit summary
Line 1: Line 1:
I think the precise statement of the problem is a little too restricted. In some cases it's possible to walk the directory tree, printing all the matching filenames with somewhat less code than it is to walk the tree in order to collect a list of the matches or to perform other operations on them. Also there are many criteria on which one might wish to select files beyond just file names. [[User:JimD|JimD]] 19:13, 15 October 2007 (MDT)
I think the precise statement of the problem is a little too restricted. In some cases it's possible to walk the directory tree, printing all the matching filenames with somewhat less code than it is to walk the tree in order to collect a list of the matches or to perform other operations on them. Also there are many criteria on which one might wish to select files beyond just file names. [[User:JimD|JimD]] 19:13, 15 October 2007 (MDT)
:This is true. The instructions could be changed to call a function, but I've been hesitant to use that abstraction for the sake of simplicity. Really, I'd just like to leave a comment along the lines of /* do something here */ in the appropriate place, but I'm not sure how to word that. --[[User:Short Circuit|Short Circuit]] 20:00, 15 October 2007 (MDT)
:This is true. The instructions could be changed to call a function, but I've been hesitant to use that abstraction for the sake of simplicity. Really, I'd just like to leave a comment along the lines of /* do something here */ in the appropriate place, but I'm not sure how to word that. --[[User:Short Circuit|Short Circuit]] 20:00, 15 October 2007 (MDT)
:: The current text of the task:
Walk a given directory tree and print files matching a given pattern.
:: My suggestion:
'''Walk a given directory tree, calling a function for every filename which matches a given wildcard, UNIX [[glob]], or [[regex]] pattern (whichever is easiest for the given language).''
: Question: would we want to create a small set of more complex tree walking tasks which ask how one would do things like: follow (or refrain from following) symbolic links, refrain from crossing UNIX/Linux mount points, select files based on their ''stat()'' criteria (such as link count, dates, ownership, group association, permissions, etc) or on their contents?


----
----

Revision as of 20:19, 16 October 2007

I think the precise statement of the problem is a little too restricted. In some cases it's possible to walk the directory tree, printing all the matching filenames with somewhat less code than it is to walk the tree in order to collect a list of the matches or to perform other operations on them. Also there are many criteria on which one might wish to select files beyond just file names. JimD 19:13, 15 October 2007 (MDT)

This is true. The instructions could be changed to call a function, but I've been hesitant to use that abstraction for the sake of simplicity. Really, I'd just like to leave a comment along the lines of /* do something here */ in the appropriate place, but I'm not sure how to word that. --Short Circuit 20:00, 15 October 2007 (MDT)
The current text of the task:
 Walk a given directory tree and print files matching a given pattern. 
My suggestion:
 'Walk a given directory tree, calling a function for every filename which matches a given wildcard, UNIX glob, or regex pattern (whichever is easiest for the given language).
Question: would we want to create a small set of more complex tree walking tasks which ask how one would do things like: follow (or refrain from following) symbolic links, refrain from crossing UNIX/Linux mount points, select files based on their stat() criteria (such as link count, dates, ownership, group association, permissions, etc) or on their contents?