2018-10-15 23:12:43 UTC
file access errors and there might be bugs, but it has cool features and
i just wanted to share.
filesystem globbing is the matching of paths that can include wildcard
characters like asterisks.
the code implements the following:
filesystem-glob :: string -> (string ...)
find files matching a file system path with optional wildcard
* matches zero or more of any character in a file name.
? matches one of any character in a file name.
** skips any sub directories to match the rest of the path. at the end
of a path it is the same as **/.* including .*
**n where n is an integer. like ** but skips directories at most n sub
to list all files in a directory recursively: dir/**
and to list all pdf files in a directory recursively: dir/**/*.pdf
here is the code with reduced dependencies so that anybody with only
guile should be able to run it:
it is now part of sph-lib:
you can play around with it on the command-line by creating an
executable file with content similar to this:
(for-each (lambda (a) (display a) (newline))
(filesystem-glob (car (cdr (program-arguments)))))
if this is in a file "mygl" then you can call it like "./mygl '/tmp/*'".
paths in single quotes, otherwise the shell evaluates the wildcards.