home *** CD-ROM | disk | FTP | other *** search
- Listing 3: Directory.ch
-
- #include "DIRECTRY.CH"
- function LoadDir(path)
- /*
- Return array containing entire directory structure of drive
- volume. This function uses a recursive call to itself.
- */
- local i, name, d_
- local r_ := {}
-
- if path = nil
- path := "\"
- endif
-
- // Load contents of the specified directory path,
- // including any subdirectory entries that might be there.
- d_ := directory(path +"*.*", "D")
-
- // Loop once for each entry in directory.
- for i := 1 to len(d_)
- name := d_[i, F_NAME]
-
- // If the file attribute indicates this
- // is a subdirectory entry, special handling is needed.
- if d_[i, F_ATTR] = "D"
-
- // Skip the "." and ".." entries.
- if .not. (name $ "..")
-
- // Add the subdirectory name to the array
- // and call the directory loader function to
- // return the array of file names.
- aadd(r_, {name, LoadDir(path +name +"\")})
- endif
-
- // If the file isn't a subdirectory name,
- // add it to the array of file names.
- else
- aadd(r_, name)
- endif
- next i
-
- return r_