[Openmcl-devel] how to query a directory to be writable in CCL Mac and Win?
Pascal J. Bourguignon
pjb at informatimago.com
Wed Oct 12 12:36:14 PDT 2011
Alexander Repenning <ralex at cs.colorado.edu> writes:
> AFAIK there is no portable CL function to do this but is there some
> CCL specific way?
Just create a file in that directory.
(handler-case
(progn
(open "/some/dir/file.data" :direction :probe
:if-does-not-exist:create)
t)
(error ()
nil))
> In Cocoa and Cocotron there is a function isWritable
> but it appears to be false in some cases, e.g., folders contained in
> the Application files on Windows 7, even when files appear to be
> writable in that folder.
You could also use FFI and call access(2). But see below.
> The only strategy, I am guessing, would be to
> actually write a temp file and test if that succeeded.
This strategy is wrong too, because while you may be able to write a
temp file, one nanosecond later another process may change the access
rights to that directory, and you won't be able to create the real file
in that directory anymore.
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
More information about the Openmcl-devel
mailing list