[plt-scheme] Find-files exception when encountering unreadable directory

From: Eli Barzilay (eli at barzilay.org)
Date: Thu Jun 5 10:20:10 EDT 2008

On Jun  4, Erich Rast wrote:
> I have troubles using find-files in scheme/file (3.99) to traverse a
> directory hierarchy. For some reason, some some mounted .dmg images
> on OS X tend to have a .Trashes folders that isn't readable by the
> user, and find-files yields an exception when it encounters the
> volume's top-level .Trashes folder. I cannot get rid of these
> exceptions, no matter what I put into the predicate for find-files.
> Am I missing something obvious? Or does anyone have another
> find-files function at hand? (I'm dealing with rather large
> directories, so it should be iterative/use accumulators.)

It sounds like checking permissions of directories before scanning
them would solve the problem, but I don't think that it's a good idea
to do that always, since it will make it do more IO.  But I'm not sure
what the difference is, and if you have large directories then it
might be a good data point.  To try and make it check persmissions you
should probably start with eth currend definition of the function and

          [(directory-exists? path)

to something like

          [(directory-exists? path)
           (if (memq 'read (file-or-directory-permissions path))

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!

Posted on the users mailing list.