From c1bfb701b3f7d3e05f9216cfdab8179a9e0a6de6 Mon Sep 17 00:00:00 2001 From: Martin Gasbichler Date: Sat, 27 Mar 2004 07:53:24 +0000 Subject: [PATCH] Added DIR-STREAM-TOOLS --- scsh/dir-streams/NEWS | 3 ++- scsh/dir-streams/README | 12 ++++++++++++ scsh/dir-streams/dir-stream-tools.scm | 13 +++++++++++++ scsh/dir-streams/packages.scm | 9 +++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 scsh/dir-streams/dir-stream-tools.scm diff --git a/scsh/dir-streams/NEWS b/scsh/dir-streams/NEWS index 26f793c..a76a18c 100644 --- a/scsh/dir-streams/NEWS +++ b/scsh/dir-streams/NEWS @@ -1,2 +1,3 @@ -version 0.0 +version 1.0 * New package system. +* New structure DIR-STREAM-TOOLS \ No newline at end of file diff --git a/scsh/dir-streams/README b/scsh/dir-streams/README index 1ddb95c..3181ff5 100644 --- a/scsh/dir-streams/README +++ b/scsh/dir-streams/README @@ -169,3 +169,15 @@ file represented by FS-OBJECT. Returns #t if REGEXP-SEARCH? for regexp matches the filename (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. diff --git a/scsh/dir-streams/dir-stream-tools.scm b/scsh/dir-streams/dir-stream-tools.scm new file mode 100644 index 0000000..d5ebad3 --- /dev/null +++ b/scsh/dir-streams/dir-stream-tools.scm @@ -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)) diff --git a/scsh/dir-streams/packages.scm b/scsh/dir-streams/packages.scm index 9c8b663..2b3f4a9 100644 --- a/scsh/dir-streams/packages.scm +++ b/scsh/dir-streams/packages.scm @@ -61,6 +61,10 @@ stream-take-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 (open scheme-with-scsh handle @@ -77,6 +81,11 @@ dir-streams) (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 streams-interface (open scheme