Re: File Listings [message #6950 is a reply to message #6816] |
Thu, 29 August 1996 00:00  |
Brian C. Ballard
Messages: 3 Registered: August 1996
|
Junior Member |
|
|
Bon Jour, autre temp,
This is a summary of what I found out about my original question.
Thanks to Jim Pendletom of RSI (US) and Peter Mason of CSIRO (AU) for
their help.
Ayer, escribi:
> ---- Question ----
> Does anyone know how to get a simple directory listing (in text format)
> under windows? (Like "dir" in good old DOS.)
I feel foolish for missing the FINDFILE function in the manuals. Here's
part of what I ended up writing if anyone cares (UNIX works, Windows not
tested yet):
<begin>
...
'unix': begin
...
;Get the directory listing, send errors to bit bucket
spawn, [ '/bin/sh', '-c', 'ls -1FLa ' +path+ ' 2> /dev/null'], $
junks, count = junkv, /noshell
;Dirs will end in "/", files don't
j = where( strpos( junks, '/') ge 0, junkv)
if ( junkv eq 0) then dirs = "" $
else begin
;Build the dirs list from elements that ended in /
dirs = junks( j)
;Chop the "/" from the end of each element
for i = 0, junkv-1 do $
dirs(i) = strmid( dirs(i), 0, strlen( dirs(i))-1)
endelse
;Build file path/name, take care of root dir special case
if ( path ne '/') then $
junks2 = path + "/" + filt $
else $
junks2 = path + filt
...
end ;case UNIX
'Windows': begin
...
;Get the directory listing
junks = findfile( path + "\" + "*.*")
;Dirs will end in '\', files don't
j = where( strpos( junks, '\') ge 0, junkv)
if (junkv eq 0) then dirs = "" $
else begin
;Build the dirs list from elements that ended in "\"
dirs = junks(j)
;Chop the "\" from the end of each element
for i = 0, junkv-1 do $
dirs(i) = strmid( dirs(i), 0, strlen( dirs(i))-1)
endelse
...
end ; case Windows
...
<end>
NB: path can not end in "/" (unix) or "\" (windows).
Brian C. Ballard
E-mail: bballard@orionint.com
WWW : http://www.orionint.com/~bballard/
|
|
|