doc repairs and 'fil'->'file' printing change to dir.ss teachpack (at a teacher's request)
svn: r16500
This commit is contained in:
parent
71387d274c
commit
ccd6659100
|
@ -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)))))
|
||||
|
||||
|
|
|
@ -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 <code>dir.ss</code> and click RUN:
|
||||
Sample: Set teachpack to @filepath{dir.ss} and click RUN:
|
||||
@(begin
|
||||
#reader scribble/comment-reader
|
||||
(schemeblock
|
||||
|
|
Loading…
Reference in New Issue
Block a user