The structure dir-streams defines procedures to represent and process
directories as streams of files and sub-directories.
(dir-stream-from-dir-name dir-name [chase?] [parent]) -> dir-stream
Constructor for dir-streams.
(dir-stream? thing) -> boolean
Type predicate for dir-streams.
(dir-stream-info dir-stream) -> fs-object
Returns the fs-object corresponding to the directory.
(fs-object? thing) -> boolean
Type predicate for file-objects.
(fs-object-parent fs-object) -> string
The parent directory of the fs-object.
(fs-object-name fs-object) -> string
The file name of the fs-object.
(fs-object-info fs-object) -> file-info
The file-info record of the fs-object.
(fs-object-file-name fs-object) -> string
The path to the fs-object.
(dir-stream-files-stream dir-steam) -> fs-object stream
A stream of the fs-objects of the files within the directory.
(dir-stream-subdir-stream dir-stream) -> dir-stream stream
A stream of dir-streams of the subdirectories within the directory.
(dir-stream-filter dir-stream file-pred dir-pred) -> dir-stream
Applies the predicate DIR-PRED to all the subdirectories and FILE-PRED
to all the files within directory. The returned stream contains only
the files and subdirectories for which the predicates return #t.
(dir-stream-fold-right ds make-dir-stream
files-make-stream files-stream-empty
subdirs-make-stream subdirs-empty) -> return type of make-dir-stream
Replaces the constructors of the dir-stream by the supplied procedures.
Example:
(define (disc-usage ds)
(dir-stream-fold-right ds (lambda (fso sum subdirs) (list (fs-object-filename fso)
(apply + sum (map cadr subdirs))
subdirs))
(lambda (fso accu)
(+ accu (file-info:size (fs-object-info fso))))
0
cons
'()))
(dir-stream-map dir-stream-map-f dir-stream file-f dir-f)
TODO argument order
(dir-stream-filter-map dir-stream-map-f dir-stream file-f dir-f)
(dir-stream-for-each dir-stream file-f dir-f)
The structure dir-stream-predicates defines some predicates the user
might find useful when programming with dir-streams.
(fs-object-size-less-than? fs-object size) -> {#t, #f}
(fs-object-size-greater-than? fs-object size) -> {#t, #f}
Check whether the lenght of the file represented by fs-object is
less/more than size bytes.
(days->seconds days) -> integer
(hours->seconds hours) -> integer
(minutes->seconds minutes) -> integer
Auxiliary functions for converting an integer representing a count of
days/hours/minutes to an integer representing that amount of time in
seconds.
(fs-object-last-modified-in? fs-object pair) -> {#t, #f}
(fs-object-last-accessed-in? fs-object pair) -> {#t, #f}
(fs-object-created-in? fs-object pair) -> {#t, #f}
pair is a pair representing an interval of time. This function checks
whether the date when then file represented by fs-object was last
modified/last-accessed/created lies in this interval (includes left
and right boundary of the interval).
(fs-object-name-matches? fs-object regexp) -> {#t, #f}
Returns true if regexp-search? for regexp matches the filename of the
file represented by fs-object.
(ds-object-file-name-matches? fs-object regexp) -> {#t, #f}
Returns true if regexp-search? for regexp matches the filename
(including the absolute path) of the file represented by fs-object.