Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 Jan 2012 02:00:12 -0600 (CST)
From:      Robert Bonomi <bonomi@mail.r-bonomi.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: access(FULLPATH, xxx);
Message-ID:  <201201140800.q0E80CSS035179@mail.r-bonomi.com>
In-Reply-To: <20120114000513.GA17888@thought.org>

next in thread | previous in thread | raw e-mail | index | archive | help
> From owner-freebsd-questions@freebsd.org  Fri Jan 13 18:15:44 2012
> Date: Fri, 13 Jan 2012 16:05:18 -0800
> From: Gary Kline <kline@thought.org>
> To: FreeBSD Mailing List <freebsd-questions@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>





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201201140800.q0E80CSS035179>