Skip to content
Tcl Source Code History Of Ticket 1880980
Login

History Of Ticket 1880980

Artifacts Associated With Ticket 1880980

  1. Ticket change [73daff148d] (rid 105103) by evil_son on 2008-01-28 07:12:34:

    1. assignee initialized to: "dkf"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      
      Currently,  to traverse a directory hierarchy: in the top directory we need to explicitly glob for all directory entries (including those that start with a period) and then filter out "." and ".." and so on recursively for children directories
      
      The following suggested option to [glob] will simplify code as well as provide some speed increase.
      
      [glob -walk] will return all directory entries in the current dir including those that start with a period _except_ for "." and ".."  i.e it filters out the current and parent directories.  Other filters can be stacked on top of it as per usual with [glob]
      
      This option does _not_ walk the entire directory tree recursively.  As such the name "-walk" may be considered misleading.
      
      [glob -walk] essentially provides a filter to a previously suggested option [glob -all]: request id 1880967 at http://sourceforge.net/tracker/index.php?func=detail&aid=1880967&group_id=10894&atid=360894
      and may well be used more often than [glob -all] raising doubts about the need for the latter.
      
      Checking for recursive links in the filesystem is still the responsibility of the user.
      
      e.g usage. To print the names of all and only directories under $root:
      
      proc rec-print-dirs {dir} {
        puts $dir
        foreach d [glob -walk -directory $dir -types {d}] {
          rec-print-dirs $d
        }
      }
      rec-print-dirs $root
      
      Thank you
      E Wilson
      
      
    4. foundin initialized to: "None"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "evil_son"
    10. subsystem initialized to: "16. Commands A-H"
    11. title initialized to: "Option to [glob] to ease recursive traversal"
    12. type initialized to: "RFE"
  2. Ticket change [2ccf970587] (rid 118974) by nobody on 2008-01-28 15:11:30:

    1. icomment:
      Logged In: NO 
      
      I think -all is a good idea provided that it does not return . and ..
      
      Given that, -walk would be equivalent to -all -types d, and thus
      redundant.
      
      
      
    2. login: "[email protected]"
    3. mimetype: "text/plain"
    4. username: "[email protected]"
  3. Ticket change [970ae1adc3] (rid 106439) by dgp on 2008-01-28 21:55:27:

    1. subsystem changed to: "36. Pathname Management"
  4. Ticket change [f9fbd80512] (rid 91793) by dkf on 2008-01-28 21:56:34:

    1. assignee changed to: "vincentdarley"
  5. Ticket change [aa769556f9] (rid 100932) by evil_son on 2008-01-29 00:37:16:

    1. icomment:
      Logged In: YES 
      user_id=1993540
      Originator: YES
      
      In response to sender "nobody",
      if -all were not to return "." and ".." then it would behave exactly like -walk.  My less specific (compared to yours) version of -all was aimed at generality while the more specific -walk (which you call -all) is the one I'd use more often .. like you and perhaps most users.
      
      Since the existing options are strong enough and we can easily wrap Tcl procedures around them, the motivation is really performance ... which raises the question is there a better interface that can provide superior performance.  I think there is but it may become too specific to directory traversal and will require more work; so I hesitated suggesting it.  I will put up another request in a couple of days describing it.
      
      Thanks for your comment
      
      
      
    2. login: "evil_son"
    3. mimetype: "text/plain"
    4. username: "evil_son"
  6. Ticket change [936fee3eea] (rid 105814) by evil_son on 2008-01-31 23:01:00:

    1. icomment:
      Logged In: YES 
      user_id=1993540
      Originator: YES
      
      Following up on my previous post: what if glob -walk returned a list of pairs <filename, type (i.e. file or dir)> of all directory entries except for . and ..
      
      So to print out files under a directory (without error checking or checking for empty return lists):
      
      proc allfiles {dir} {
        foreach pair [glob -walk -directory $dir] {
        foreach {entry type} $pair {break}
        if {$type eq "d"} { allfiles $entry }
        elseif {$type eq "f"} { puts $entry } 
        }
      }
      allfiles someDir
      
      
      
    2. login: "evil_son"
    3. mimetype: "text/plain"
    4. username: "evil_son"