Is there a racket/scheme procedure that returns a list (or vector) of the names of all user accesible files?
The output needs to be a list or vector for applying a "filter", like so:
(filter pred list-of-all-files)
The intended application is a text-based, user-friendly "librarian" program.
The relevant procedures you are looking for are directory-list and in-directory.
Using
directory-list
, you can retrieve a list of all files and directories in the directory specified by some path (similar to the shell commandls
).On the other hand,
in-directory
returns a sequence that produces all of the paths for files, directories, and links within a directory, traversing nested subdirectories recursively (which seems to be what you are primarily looking for).For example, to return the names of all user readable files and directories under
"/some/path"
, you can do:You can use path->string to produce the file names in string format instead. So, to create your
list-all-files
procedure:Then, you can
filter
the generated list using any predicatepred
: