Directories


dir.ss

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

  • (define-struct dir (names dirs files))
  • (define-struct file (name size content))
  • create-dir which consumes a directory path (a string) and produces a directory.
  • For data definitions, see section 15.

    The teachpack relies on two data definitions:

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

    Note: Softlinks are always treated as if they were empty files.