{ (define LIBNAME "Directories") (include "head.tinc") }

The teachpack dir.ss provides two-structures and one operation:

  • (define-struct dir (names dirs files))
  • (define-struct file (name size content))
  • {(idx create-dir)} which consumes a directory path (a string) and produces a directory.
  • The teachpack relies on two data definitions:

  • A directory is ({(idx make-dir)} string[path] (listof directory) (listof file))
  • A file is ({(idx make-file)} string[file name])
  • Sample: Set teachpack to dir.ss and execute. Then evaluate
    > (create-dir ".")
    (make-dir
      '|.|
      empty
      (cons (make-file 'ball1.gif 1289 empty)
            (cons (make-file 'blueball.gif 205 empty)
                  (cons (make-file 'greenbal.gif 204 empty)
                        (cons (make-file 'redball.gif 203 empty)
                              (cons (make-file 'ufo.gif 1044 empty)
                                    (cons (make-file 'gif-test.ss 5811 empty)
                                          empty)))))))
    

    Note: Softlinks are always treated as if they were empty files. {(include "foot.tinc")}