[racket] filesystem api

From: Nikita B. Zuev (nikitazu at gmail.com)
Date: Sun Jun 5 10:19:57 EDT 2011


I'm writing a program, that needs to walk recursively through a
filesystem directory structure.
Looking through documentation I found only `directory-list' function, that can
list directory content. The problem is, I haven't found any high level
data structures representing
filesystem, `directory-list' just returns a list of paths. Having only
`path' available,
I guessed the only way to know if `path' represents file or directory,
is through a call
to `directory-exists?' (I know that it exists, but it will return #f
for files). If I understand
correctly now my `directory-tree-fold' function hits filesystem as
many times, as I
have files + (directories * 2): one call to `directory-list' per
directory and one call to
`directory-exists?' per every file and folder.

Is there a way to list directory's files and subdirectories separate from each
other (something like `directory-list-files',
`directory-list-subdirs'). Or maybe
there is some way to get a list of structs, representing filesystem objects,
and having fields like `is-file?' or 'is-directory?'.

Nikita B. Zuev

Posted on the users mailing list.