File: dir.html

package info (click to toggle)
drscheme 1%3A352-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 71,608 kB
  • ctags: 55,284
  • sloc: ansic: 278,966; cpp: 63,318; sh: 32,265; lisp: 14,530; asm: 7,327; makefile: 4,846; pascal: 4,363; perl: 2,920; java: 1,632; yacc: 755; lex: 258; sed: 93; xml: 12
file content (54 lines) | stat: -rw-r--r-- 1,557 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<html>
<head>
<title>Teachpack : Directories</title>
</head>
<body bgcolor="#ffffff" text="#000000"
      link="#009900" vlink="#007700" alink="#cc0000">

<a href="index.html">Teachpacks for How to Design Programs</a>

<h1>Directories</h1>

<hr> <h3><a name="dir.ss">dir.ss</a></h3> <!-- DOCNOTE="teach=dir.ss" -->

<p>The teachpack <code>dir.ss</code> provides two-structures and one
operation:
<menu>
  <li> <code>(define-struct dir (names dirs files))</code>

  <li> <code>(define-struct file (name size content))</code>

  <li> <code><a name="create-dir">create-dir</a></code> which consumes a directory path (a string)
       and produces a directory.
</menu>

<p>The teachpack relies on two data definitions:
<menu>
<li>
   A directory is
   <code>(<a name="make-dir">make-dir</a> string[path] (listof directory) (listof file))</code>
<li>
   A file is <code>(<a name="make-file">make-file</a> string[file name])</code>
</menu>

Sample: Set teachpack to <code>dir.ss</code> and execute. Then evaluate
<pre>
> (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)))))))
</pre>

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

<br>
<br>
</body>
</html>