On 10.11.2005 01:53, "John Stiles" <email@hidden> wrote:
> The easiest way to learn whether a file can be written to is to open the file
> with write permission and then immediately close it. If you were able to open
> it, it's writable. This is safe to do and doesn't take a long time.
According to <http://developer.apple.com/technotes/fl/fl_37.html>, opening
files on read-only volumes with fsRdWrPerm of fsWrPerm should succeed,
falling back to read/deny-write or similar. Ancient documentation, but still
true for some file systems (AFP, but not SMB, rdar://3755430).
-------------------------------------------------
An open with write permission request (fsCurPerm, fsWrPerm, fsRdWrPerm, or
fsRdWrShPerm) does not fail on a locked volume and the write bit in
ioFCBFlags returned by PBGetFCBInfo will be set indicating that data can be
written to the file. As noted in Inside Macintosh: Files on page 2-8, you
won't discover this until you receive an error (either vLckdErr or wPrErr)
on the first call that attempts to write to the file or change the file's
logical or physical end-of-file. You can preflight for this condition by
calling PBHGetVInfo and checking the hardware and software locked bits in
ioVAtrb.
-------------------------------------------------
<...>
-------------------------------------------------
fsRdWrPerm is also retried as read-only, to simulate the case where a file
is being opened from a locked disk. Elsewhere, it's pointed out that
fsRdWrPerm is granted even if the volume is locked, and that an error won't
be returned until a PBWrite (or PBSetEOF or PBAllocate) call is made. The
same is now true for a read-only folder on an AppleShare volume.
-------------------------------------------------
- WBR, Alexey Proskuryakov
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden
This email sent to email@hidden