► |  | Teachpacks

1 | Ht DP Teachpacks
2 | Ht DP/ 2e Teachpacks

▼ | 1 | Ht DP Teachpacks

1.1 | Manipulating Images: "image.ss"
1.2 | Simulations and Animations: "world.ss"
1.3 | Converting Temperatures: "convert.ss"
1.4 | Guessing Numbers: "guess.ss"
1.5 | Master Minding: "master.ss"
1.6 | Simple Drawing: "draw.ss"
1.7 | Hangman: "hangman.ss"
1.8 | Managing Control Arrows: "arrow.ss"
1.9 | Manipulating Simple HTML Documents: "docs.ss"
1.10 | Working with Files and Directories: "dir.ss"
1.11 | Graphing Functions: "graphing.ss"
1.12 | Simple Graphical User Interfaces: "gui.ss"
1.13 | An Arrow GUI: "arrow-gui.ss"
1.14 | Controlling an Elevator: "elevator.ss"
1.15 | Queens: "show-queen.ss"
1.16 | Matrix Operations: "matrix.ss"

On this page:

dir
file
create-dir

top ← prev up next →

#### 1.10`` Working with Files and Directories: "dir.ss"

The teachpack provides structures and operations for working with files and directories:

( struct |  | dir (name dirs files)
|  | #:extra-constructor-name make-dir )

name : symbol?
dirs : ( listof dir? )
files : ( listof file? )

( struct |  | file (name size content)
|  | #:extra-constructor-name make-file )

name : symbol?
size : integer?
content : ( listof char? )

( create-dir path) → dir?
path : symbol?

Turns the directory found at path on your computer into an instance of dir?.

Sample: Set teachpack to "dir.ss" and click RUN:

> ( 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)))))))

Using “.” usually means the directory in which your program is located. In this case, the directory contains no sub-directories and six files.

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

top ← prev up next →