…
|
||
---|---|---|
.. | ||
AUTHORS | ||
BLURB | ||
README | ||
dir-stream-predicates.scm | ||
dir-stream.scm | ||
interfaces.scm | ||
packages.scm | ||
stream.scm |
README
The structure DIR-STREAMS defines procedures to represent and process directories as streams of files and sub-directories. Using a lazy data structure to represent directories allows the library to minimize access to the file system. Files within streams are represented by the data type FS-OBJECT which essentially extends scsh's FILE-INFO type by a field for the file name. In addition the structure STREAM provides a library for stream processing but we intend to replace this library with SRFI-40 soon. This is also the reason for the lack of documentation for the STREAM package. (dir-stream-from-dir-name dir-name [chase?] [parent]) -> dir-stream Constructor for dir-streams. The CHASE? option indicates whether symbolic links should be followed or not and defaults to #t. PARENT is the directory relative to which DIR-NAME should be interpreted. It defaults to "" and is only mildly useful. (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 FS-OBJECT. (fs-object-info fs-object) -> file-info The file-info record of FS-OBJECT. (fs-object-file-name fs-object) -> string The path of FS-OBJECT. (dir-stream-files-stream dir-steam) -> fs-object stream A stream of the fs-objects of the files within the directory represented by DIR-STREAM. (dir-stream-subdir-stream dir-stream) -> dir-stream stream A stream of dir-streams of the subdirectories within the directory represented by DIR-STREAM. (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 file-f dir-f) -> dir-stream Applies FILE-F to all files in DIR-STREAM and DIR-F to all directories in DIR-STREAM and returns the resulting dir-stream. (dir-stream-filter-map dir-stream file-f dir-f) -> dir-stream Applies FILE-F to all files in DIR-STREAM and DIR-F to all directories in DIR-STREAM and returns the dir-stream containing all the non-false results of FILE-F and DIR-F. (dir-stream-for-each dir-stream file-f dir-f) -> unspecific Applies FILE-F to all files in DIR-STREAM and DIR-F to all directories in DIR-STREAM. 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. These functions check 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 #t 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 #t if REGEXP-SEARCH? for regexp matches the filename (including the absolute path) of the file represented by FS-OBJECT.