Re: How to know a file is writeable?
Re: How to know a file is writeable?
- Subject: Re: How to know a file is writeable?
- From: "John C. Daub" <email@hidden>
- Date: Fri, 25 Feb 2005 11:04:00 -0600
on 2/25/05 10:18 AM, Steve Bird at email@hidden wrote:
> On Feb 25, 2005, at 9:34 AM, John C. Daub wrote:
>
>> To give an example, let's say you're writing an application that does file
>> system browsing. The user browses to some directory, and it's reasonable to
>> use something like access() or the NSFileManager routines or the
>> kFSCatInfoUserAccess information to display a "slashed out pencil" icon to
>> say you can't write to that directory. If the user explicitly tries to copy
>> something into that directory via your app, you shouldn't just say no but
>> should actually try the copy. Thus the success or failure of the copy is
>> ultimately and properly determined by the file system.
>
> --- I understand your thinking that it's possible the situation may
> have changed between the time the icon was presented and the time the
> operation was attempted, but I have to express something concerning
> your advice.
>
> One of my biggest peeves with Windows (and Windows programmers) is
> their willingness (obsession?) with doing just what you said.
>
> I just finished a session with ZoneAlarm which was most frustrating: It
> allows me to select an item from a list then click an operator button
> to operate on that item. But certain items are prohibited from having
> that operation done - so what does it do? It puts up an error alert
> saying "You can't do that".
>
> To which my immediate question is: "Then why did you let me click on
> the button? After all, you knew I couldn't do that before I did!"
>
> I vaguely remember this being in the Human Interface Guidelines (back
> when such things were respected), and it turns out to make easier
> programming anyway. The buttons, menus, etc are always in a state
> where actions that are impossible at the moment are not available.
>
> Perhaps that fuels my frustration - hoping that Apple's 1986 HI
> guidelines would apply to 2005's Windows programmers, but a good idea
> is a good idea.
Oh I completely understand what you mean. And in general yes I agree with
you. Note that what I gave was just an example to help explain things, to
make it a little more concrete. So like all examples, it's simplification
and not necessarily something you'd want to do in real life... it's just
there to aid in understanding the concept being explained. :-)
It's just that this is the reality of the original poster's particular
situation. There isn't a good way to determine the writability/deletability
of a file -- those techniques like access() can only give a best guess. And
even if you tried to determine this by a more reliable method (e.g. you
determine by actually opening the file for writing, then immediately closing
it), you still have that potential for the race condition of the
writability/deletability changing in the interval between the check and then
actually doing it. So despite all your best efforts, you can still end up in
a frustrating situation like you describe above.
What it really comes down to is you determining just what you're trying to
do and why you need that information in the first place. And you just have
to understand the reality of the technical issues and then try to resolve
all of these things towards giving your users the best user experience you
can all of these things considered.
Again, I agree with your sentiment. It just that in a case like this,
there's no ideal way to accomplish what you want. :-( So you just have to
consider your particular situation and do the best you can given the cards
we're all dealt.
--
John C. Daub }:-)>=
<mailto:email@hidden> <http://www.hsoi.com/>
"Nothing is greater than love or surrender." -- Buddo
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden