PDA

View Full Version : Detect Read-Only file attribute



msretenovic
2004-07-22, 05:31 PM
Hello all,

I'm writing a routine and have come across a slight snag. I have this code:



(if (not (vl-catch-all-apply 'vla-open (list dbxDoc dwg)))
(progn
;;do my stuff here
(vla-saveas- dbxDoc dwg)
)
)


This works really well until I come to a file that is Read-Only :-? . It will do as I expect when the file is Read-Only when someone has it open, but if it's file attribute is Read-Only, it doesn't catch it :-x . Does any know a way around this or how to check to see if a file has a Read-Only attribute :grin: ?

TIA

Mike.Perry
2004-07-22, 05:44 PM
Hi Mike

Check out the following article by Stig Madsen -

Scripting objects (http://www.afralisp.com/lisp/script1.htm)

Way over my head :???: but I'm pretty sure you can/could achieve what you're after using the methods described in the article.

Have a good one, Mike

RobertB
2004-07-22, 05:54 PM
Here is a simple method too:


(defun IsRO (fileN / fileH)
(cond ((setq fileH (open fileN "a"))
(close fileH)))
(not fileH))

msretenovic
2004-07-22, 06:49 PM
Robert,

That is exactly what I was looking for :grin:. So simple, yet so effective :-).

:Puffy:

Thanks

RobertB
2004-07-22, 11:02 PM
Glad I could help!