From ccd6659100201bf19e8c83b44b8c4c2cf6f45829 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 2 Nov 2009 12:26:06 +0000 Subject: [PATCH] doc repairs and 'fil'->'file' printing change to dir.ss teachpack (at a teacher's request) svn: r16500 --- collects/htdp/dir.ss | 19 ++++++++----------- collects/teachpack/htdp/scribblings/dir.scrbl | 13 +++++++------ 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/collects/htdp/dir.ss b/collects/htdp/dir.ss index 16773119db..b592311bb2 100644 --- a/collects/htdp/dir.ss +++ b/collects/htdp/dir.ss @@ -1,7 +1,8 @@ #lang scheme (require htdp/error - lang/prim) + lang/prim + (only-in scheme/base [file-size s:file-size])) (provide create-dir ; path -> Directory @@ -14,16 +15,12 @@ dir-files ; structure - (rename-out (fil? file?) - (make-fil make-file) - (fil-name file-name) - (fil-content file-content) - (fil-size file-size)) + file? make-file file-name file-content file-size ) ;; Structures: (define-struct dir (name dirs files) #:transparent) -(define-struct fil (name size content) #:transparent) +(define-struct file (name size content) #:transparent) (define-primitive create-dir create-dir/proc) @@ -45,9 +42,9 @@ (make-dir (string->symbol (path->string (my-split-path d))) (explore (map (lambda (x) (build-path d x)) ds)) - (map make-fil + (map make-file (map (compose string->symbol path->string) fs) - (map (lambda (x) (if (file-exists? x) (file-size x) 0)) + (map (lambda (x) (if (file-exists? x) (s:file-size x) 0)) (map (lambda (x) (build-path d x)) fs)) (map (lambda (x) (if (link-exists? x) 'link null)) fs))))) dirs)) @@ -76,6 +73,6 @@ ;; option to expand the library ... ;; cache it ... (define (get-file-content f) - (read-string (fil-size f) - (open-input-file (symbol->string (fil-name f))))) + (read-string (file-size f) + (open-input-file (symbol->string (file-name f))))) diff --git a/collects/teachpack/htdp/scribblings/dir.scrbl b/collects/teachpack/htdp/scribblings/dir.scrbl index 095434a659..a106dd670e 100644 --- a/collects/teachpack/htdp/scribblings/dir.scrbl +++ b/collects/teachpack/htdp/scribblings/dir.scrbl @@ -2,7 +2,8 @@ @(require scribble/manual "shared.ss" (for-label (except-in scheme/base file-size) - teachpack/htdp/dir)) + teachpack/htdp/dir + scheme/contract)) @teachpack["dir"]{Working with Files and Directories} @@ -11,14 +12,14 @@ The teachpack provides structures and operations for working with files and directories: -@defstruct[dir ([name string?][dirs (list-of dir?)][files (list-of file?)])]{} +@defstruct[dir ([name symbol?][dirs (listof dir?)][files (listof file?)])]{} -@defstruct[file ([name string?][content (list-of char?)])]{} +@defstruct[file ([name symbol?][size integer?][content (listof char?)])]{} -@defproc[(create-dir [path string?]) dir?]{ +@defproc[(create-dir [path symbol?]) dir?]{ Turns the directory found at @scheme[path] on your computer into an instance of @scheme[dir?].} -Sample: Set teachpack to dir.ss and click RUN: +Sample: Set teachpack to @filepath{dir.ss} and click RUN: @(begin #reader scribble/comment-reader (schemeblock @@ -38,4 +39,4 @@ Using ``.'' usually means the directory in which your program is located. In this case, the directory contains no sub-directories and six files. -Note: Softlinks are always treated as if they were empty files. +Note: Soft links are always treated as if they were empty files.