I think that I discovered a bug in posixwin.scm. 

I'm building a filesystem crawler that visits each file in an NTFS filesystem and hashes it. I've noticed that the crawler fails to hash files with read-only permissions. I debugged my code and I noticed that file-read-access? returned #f for read-only files in Windows XP while returning #t for similar files in Mac OS X. I noticed similar issues with file-write-access?.

To reproduce the bug in Windows: Create a test file, say "bogus.txt" and use attrib to make it read-only: "attrib +R bogus.txt". Invoke csi and use the posix extension. Invoking (file-read-access? "bogus.txt") returns #f instead of the expected #t.

I looked at posixwin.scm and consulted some Windows references and came to the conclusion that the foreign variables _r_ok, _w_ok, _x_ok are set to the wrong values in posixwin.scm. I then patched posixwin.scm with what I believe are the correct values:

1074,1076c1074,1076
< (define-foreign-variable _r_ok int "2")
< (define-foreign-variable _w_ok int "4")
< (define-foreign-variable _x_ok int "2")
---
> (define-foreign-variable _r_ok int "1")
> (define-foreign-variable _w_ok int "2")
> (define-foreign-variable _x_ok int "1")

and rebuilt chicken in Windows using Visual C++. Things are now working as I would expect them. Anybody else experienced this with Chicken Scheme and Windows?

Alden
-----
Alden Dima  - [EMAIL PROTECTED]
Computer Scientist,
Information Technology Laboratory
National Institute of Standards and Technology
Gaithersburg, MD USA

_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to