home *** CD-ROM | disk | FTP | other *** search
- /* This function displays all the files in the directory you select and its
- subdirectories.
- */
-
-
- /* dirtree.rexx - lists all files in a directory, including subdirectories.
- Ron Shaw Wed Dec 6 16:33:44 1989
- */
-
- arg root sil
-
- if right(root,1) ~= ':' then
- root = root || '/'
- if root = '/' then root = ''
-
- /*-- Added this so we could quiet the display of dir and file names --*/
- if length(sil) > 0 then sil = 0
- else sil = 1
- fcount = 0 /* # of files */
- dcount = 0 /* # of directories */
-
-
- call dotree(root)
- say ' '
- say 'sub directories['dcount'] files['fcount']'
- exit
-
- dotree: procedure expose fcount root dcount sil
- parse arg x
- contents = showdir(x);
- do i = 1 to words(contents)
- temp = x || word(contents,i)
-
- select
- when word(statef(temp),1) = 'FILE' then do
- call do_file temp
- fcount = fcount + 1 /* increment the # of files we have found */
- end
-
- /* if a directory then do next level,here is the reclusiveness ! */
- when word(statef(temp),1) = 'DIR' then do
- say temp '(DIR)'
- dcount = dcount +1
- call dotree(temp || '/')
- end
- otherwise signal about_it
- end
- end
- return 0
-
- do_file: /* this is where we do what we want with the file */
- arg fyl
-
- if compare(sil,'1') == 0 then say fyl /* display file name if asked for */
-
- return 0
-
- about_it: /* error determining file type */
- say 'Error: File' temp 'is neither DIR nor FILE.'
- exit(20)
-