access(FULLPATH, xxx);

Robert Bonomi bonomi at mail.r-bonomi.com
Sat Jan 14 07:56:49 UTC 2012


> From owner-freebsd-questions at freebsd.org  Fri Jan 13 18:15:44 2012
> Date: Fri, 13 Jan 2012 16:05:18 -0800
> From: Gary Kline <kline at thought.org>
> To: FreeBSD Mailing List <freebsd-questions at freebsd.org>
> Cc: 
> Subject: access(FULLPATH, xxx);
>
>
> excuse this slip of memory, but do you need the full path PLUS  the
> filename to use access? or just the filename?
>
> say that i'm i n ~/tmp/foob and want to deetermine  wheether i can
> access file foob.  do i need to use "access("home/kline/tmp/foob", F_OK)"
> or will "access("foob", F_OK)"  do the trick?  i have already rub 
> "chdir("~/tmp")" in main(). please note.

To repeat some advice from one of my Computer Science professors, many years
ago, whenever I asked 'how does it work' questions: "Try it and find out."

That is -not- a flippant brush-off, but a rather profound truth. (Admittedly,
it did take me a while to understand that, but the professor *WAS* absolutely 
correct with that response.)

You see, the *ONLY* thing that matters is 'what the machine does'.  And,
a trivial test case will give an _authoritative_ answer.   Anything that
anybody says about 'how it works' is merely an *opinion*, and they could
be wrong.  The test case will, however, ALWAYS give you the 'hard truth'
about how it works in your environment.

If you have the skills to use an answer to the question you asked, you have
the skills to write the 'test case' program. 

And there is one other SIGNIFICANT benefit to doing so -- you will have an
*immediate* answer to your question, rather than having to wait for 'someone
else' to do the necesary research for you'.

'Try it and find out' -- you'll be amazed at how quickly it works.  <grin>




More information about the freebsd-questions mailing list