This will print out all files and directories, starting from the current directory.
#lang racket (for ([d (in-directory)]) (printf "d: ~s\n" d)) You may also want to check out the directory-exists? and file-exists? primitives. hth, Robby On Sun, Jun 5, 2011 at 7:19 AM, Nikita B. Zuev <nikit...@gmail.com> wrote: > Hello, > > 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?'. > > > -- > Regards, > Nikita B. Zuev > _________________________________________________ > For list-related administrative tasks: > http://lists.racket-lang.org/listinfo/users > _________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/users