1. Re: walk_dir issue
- Posted by Greg Haberek <ghaberek at gmail.com> Nov 24, 2004
- 467 views
- Last edited Nov 25, 2004
> > Hi all, > > with Eu 2.5 alpha there is still this issue, that Derek had reported > regarding Eu 2.4. > > The following code is slightly modified after 'lib_u_z.htm': > }}} <eucode> > include file.e > > function look_at (sequence path_name, sequence entry) > printf(1, "%s\\%s: %d\n", {path_name, entry[D_NAME], entry[D_SIZE]}) > return 0 -- keep going > end function > > ? walk_dir("C:\\*.txt", routine_id("look_at"), 0) > </eucode> {{{ > > You can see the effect that I mean only, if there actually is at least > 1 .TXT file in directory C:\\. On my system it prints: > -------------------------------- > C:\*.txt\BOOTLOG.TXT: 59462 > C:\*.txt\SETUPLOG.TXT: 89512 > 0 > -------------------------------- > Rob, is this actually the way you want walk_dir() to work? > > Shouldn't it be > -------------------------------- > C:\BOOTLOG.TXT: 59462 > C:\SETUPLOG.TXT: 89512 > 0 > -------------------------------- > instead? > > Regards, > Juergen Its my understanding that walk_dir() uses whatever directory you feed it, without determining the *actual* directory. And since dir() can accept wildcards, things work. Why not just do this:
include file.e include wildcard.e function look_at (sequence path_name, sequence entry) if wildcard_match( "*.txt", lower(entry[D_NAME]) ) then printf(1, "%s\\%s: %d\n", {path_name, entry[D_NAME], entry[D_SIZE]}) end if return 0 -- keep going end function ? walk_dir("C:\\", routine_id("look_at"), 0)
~Greg