Added DIR-STREAM-TOOLS

This commit is contained in:
Martin Gasbichler 2004-03-27 07:53:24 +00:00
parent 1d23202be6
commit c1bfb701b3
4 changed files with 36 additions and 1 deletions

View File

@ -1,2 +1,3 @@
version 0.0 version 1.0
* New package system. * New package system.
* New structure DIR-STREAM-TOOLS

View File

@ -169,3 +169,15 @@ file represented by FS-OBJECT.
Returns #t if REGEXP-SEARCH? for regexp matches the filename Returns #t if REGEXP-SEARCH? for regexp matches the filename
(including the absolute path) of the file represented by FS-OBJECT. (including the absolute path) of the file represented by FS-OBJECT.
The structure DIR-STREAM-TOOLS offers two small applications of the library:
(dir-stream-disc-usage dir-stream) -> list
Returns a list with three elements: the name of the directory, the
disc usage in bytes, and a list of the sub-directories in the same
format.
(dir-stream-display dir-stream) -> unspecific
Displays DIR-STREAM.

View File

@ -0,0 +1,13 @@
(define (dir-stream-disc-usage ds)
(dir-stream-fold-right ds (lambda (fso sum subdirs)
(list (fs-object-file-name fso)
(apply + sum (map cadr subdirs))
subdirs))
(lambda (fso accu)
(+ accu (file-info:size (fs-object-info fso))))
0
cons
'()))
(define (dir-stream-display ds)
(dir-stream-for-each ds display display))

View File

@ -61,6 +61,10 @@
stream-take-while stream-take-while
stream-drop-while)) stream-drop-while))
(define-interface dir-stream-tools-interface
(export dir-stream-disc-usage
dir-stream-display))
(define-structure dir-streams dir-streams-interface (define-structure dir-streams dir-streams-interface
(open scheme-with-scsh (open scheme-with-scsh
handle handle
@ -77,6 +81,11 @@
dir-streams) dir-streams)
(files dir-stream-predicates)) (files dir-stream-predicates))
(define-structure dir-stream-tools dir-stream-tools-interface
(open scheme-with-scsh
dir-streams)
(files dir-stream-tools))
(define-structure streams (define-structure streams
streams-interface streams-interface
(open scheme (open scheme