From owner-freebsd-hackers@FreeBSD.ORG Mon Aug 21 19:13:57 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 6EF6816A4DE for ; Mon, 21 Aug 2006 19:13:57 +0000 (UTC) (envelope-from peterjeremy@optushome.com.au) Received: from mail02.syd.optusnet.com.au (mail02.syd.optusnet.com.au [211.29.132.183]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7D67043D5D for ; Mon, 21 Aug 2006 19:13:55 +0000 (GMT) (envelope-from peterjeremy@optushome.com.au) Received: from turion.vk2pj.dyndns.org (c220-239-19-236.belrs4.nsw.optusnet.com.au [220.239.19.236]) by mail02.syd.optusnet.com.au (8.12.11/8.12.11) with ESMTP id k7LJDsAo002527 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Tue, 22 Aug 2006 05:13:54 +1000 Received: from turion.vk2pj.dyndns.org (localhost.vk2pj.dyndns.org [127.0.0.1]) by turion.vk2pj.dyndns.org (8.13.6/8.13.6) with ESMTP id k7LJDs1Z003165; Tue, 22 Aug 2006 05:13:54 +1000 (EST) (envelope-from peter@turion.vk2pj.dyndns.org) Received: (from peter@localhost) by turion.vk2pj.dyndns.org (8.13.6/8.13.6/Submit) id k7LJDso0003164; Tue, 22 Aug 2006 05:13:54 +1000 (EST) (envelope-from peter) Date: Tue, 22 Aug 2006 05:13:54 +1000 From: Peter Jeremy To: mal content Message-ID: <20060821191354.GA729@turion.vk2pj.dyndns.org> References: <8e96a0b90608210805m561e29e5g41bdd25ff9dfa94c@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="lrZ03NoBR/3+SXJZ" Content-Disposition: inline In-Reply-To: <8e96a0b90608210805m561e29e5g41bdd25ff9dfa94c@mail.gmail.com> X-PGP-Key: http://members.optusnet.com.au/peterjeremy/pubkey.asc User-Agent: Mutt/1.5.12-2006-07-14 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: Mon, 21 Aug 2006 19:13:57 -0000 --lrZ03NoBR/3+SXJZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. --=20 Peter Jeremy --lrZ03NoBR/3+SXJZ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (FreeBSD) iD8DBQFE6gXy/opHv/APuIcRAiBaAJ0TepOIAZzKg3tZbDd8VtoVHSEXVgCgwTv8 AOwdgH3HHN+u87y2DudzzLk= =oQJv -----END PGP SIGNATURE----- --lrZ03NoBR/3+SXJZ--