From owner-freebsd-hackers@FreeBSD.ORG Tue Aug 22 00:33:23 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 422EC16A4DD for ; Tue, 22 Aug 2006 00:33:23 +0000 (UTC) (envelope-from artifact.one@googlemail.com) Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.184]) by mx1.FreeBSD.org (Postfix) with ESMTP id 82B0A43D49 for ; Tue, 22 Aug 2006 00:33:22 +0000 (GMT) (envelope-from artifact.one@googlemail.com) Received: by nf-out-0910.google.com with SMTP id n29so2238687nfc for ; Mon, 21 Aug 2006 17:33:21 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=googlemail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=ffqnrsnmabfYBvb+iGhHCFLJnAvtALXWhglY9NJKCq4A6YSGCITo4k288zB50/xx+E0oQ1GTzqlVGT16blAT+L5Xd3vqPPa/FhbNWBe/+FO9YqOvxgMY/24CInMhNZiv3rTBw7scU+XTkFxYCHu7L5Ky9T7eO14chH3Ihwg8g8k= Received: by 10.49.55.13 with SMTP id h13mr261250nfk; Mon, 21 Aug 2006 17:33:21 -0700 (PDT) Received: by 10.49.54.3 with HTTP; Mon, 21 Aug 2006 17:33:21 -0700 (PDT) Message-ID: <8e96a0b90608211733g8e47320y91be86a3c624108b@mail.gmail.com> Date: Tue, 22 Aug 2006 01:33:21 +0100 From: "mal content" To: "Peter Jeremy" In-Reply-To: <20060821191354.GA729@turion.vk2pj.dyndns.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <8e96a0b90608210805m561e29e5g41bdd25ff9dfa94c@mail.gmail.com> <20060821191354.GA729@turion.vk2pj.dyndns.org> Cc: freebsd-hackers@freebsd.org Subject: Re: Relative paths [was: Path transformation] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Aug 2006 00:33:23 -0000 On 21/08/06, Peter Jeremy wrote: > On Mon, 2006-Aug-21 16:05:33 +0100, mal content wrote: > >I have another favour to ask: Is there a function that can > >take two absolute paths and generate a relative path, from > >source to destination? > > I don't think there's any such function. My suggestion is to roll > your own, based on realpath(3) by replacing the getcwd() with the > first path and adding enough '../' to the second path to reach a > common directory (or root) from the first path. Done and done! Just checking to see that nobody had already done it in the tree somewhere. cheers, MC