[racket] Behavior of file-exists? and directory-list

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Thu Dec 6 17:17:39 EST 2012

file-exists? checks if it a FILE, it returns false on directories, links
(shortcuts), special files, etc.

Could that be it?

Jay


On Thu, Dec 6, 2012 at 3:13 PM, Tim Nelson <tbnelson at gmail.com> wrote:

> Dear Benevolent Racketeers,
>
> I just installed DrRacket 5.3.1 on my Windows 8 Laptop. (Yes,
> Windows 8, please don't laugh at me. :-) ) I have not checked
> this on other operating systems or other versions of Racket.
>
> One of my Racket projects scans the PATH directories to locate
> the Java executable, if one is installed. I have the
> executable "java.exe" present in the C:\Windows\System32 folder,
> yet:
>
> > (file-exists? "C:\\Windows\\System32")
> #f
>
> To check myself, I invoked and manually scanned
> down (directory-list "C:\\Windows\\System32"), expecting to see
> #<path:java.exe> but did not.
>
> Moreover, counting hidden files and subfolders, I had 3576 files
> in that folder (confirmed via command prompt, not recursive). If
> I don't include hidden files, I have 3238. But:
>
> > (length (directory-list "C:\\Windows\\System32"))
> 2739
>
> So it appears that (directory-list) is missing several hundred
> files that actually exist, including java.exe. java.exe is not
> hidden, not read-only, and it's not obviously a link. (And
> even if it was, shouldn't file-exists? and directory-list
> include it?)
>
> On my Windows 7 PC at home, directory-list finds java.exe, but still
> lists a hundred plus fewer files than appear via DIR:
>
> > (length (directory-list "C:\\Windows\\System32"))
> 2389
>
> C:\Windows\System32>DIR
> 2720 File(s) ...
> 91 Dir(s) ...
>
> I'm stumped. I even tried to track directory-list to its source,
> but lost the scent in pre-base.rkt.
>
> What am I missing here? Is this a potential problem with these
> functions in Windows 7 and 8, or am I perhaps using them incorrectly?
>
> Thanks,
> - Tim
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
>


-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20121206/ab4c3127/attachment.html>

Posted on the users mailing list.