From owner-freebsd-questions@FreeBSD.ORG Sat Jan 14 07:56:49 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 81BA5106564A for ; Sat, 14 Jan 2012 07:56:49 +0000 (UTC) (envelope-from bonomi@mail.r-bonomi.com) Received: from mail.r-bonomi.com (mx-out.r-bonomi.com [204.87.227.120]) by mx1.freebsd.org (Postfix) with ESMTP id 50AAC8FC0A for ; Sat, 14 Jan 2012 07:56:48 +0000 (UTC) Received: (from bonomi@localhost) by mail.r-bonomi.com (8.14.4/rdb1) id q0E80CSS035179 for freebsd-questions@freebsd.org; Sat, 14 Jan 2012 02:00:12 -0600 (CST) Date: Sat, 14 Jan 2012 02:00:12 -0600 (CST) From: Robert Bonomi Message-Id: <201201140800.q0E80CSS035179@mail.r-bonomi.com> To: freebsd-questions@freebsd.org In-Reply-To: <20120114000513.GA17888@thought.org> Subject: Re: access(FULLPATH, xxx); X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jan 2012 07:56:49 -0000 > 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 > To: FreeBSD Mailing List > 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.