comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » relative path from one absolute path to another?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
relative path from one absolute path to another? [message #49680] Tue, 08 August 2006 07:18 Go to next message
born.in.sssr@gmail.co is currently offline  born.in.sssr@gmail.co
Messages: 3
Registered: August 2006
Junior Member
Hi all,
is there an easy way (without string scripting) to get the relative
path from one absolute path to another (platform independent:
unix+win)?
In the kind of:
rel_path = get_rel_path(from_path, to_path)
Thanks, Maxim
Re: relative path from one absolute path to another? [message #49709 is a reply to message #49680] Fri, 11 August 2006 01:14 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
JD Smith <jdsmith@as.arizona.edu> writes:
> On Wed, 09 Aug 2006 15:17:15 -0400, Craig Markwardt wrote:
>> JD Smith <jdsmith@as.arizona.edu> writes:
>>> Does it work for Windows paths (with c:\foo or \\host\foo)?
>>
>> Sure. Of course, if the drive letter is different, there is no
>> possible relative path.
>
> So you explicitly test for and separate out the drive letter and then
> prepend it later? I didn't see where you do this (and I don't have any
> Windows IDL at hand to test these things).

No explicit test was needed. :-)

>
>> Regarding links and FILE_SAME(), I didn't assume the directories
>> actually exist on disk. In my case, sometimes the relative path is
>> devised before the tree exists, so that assumption would have failed.
>
> It's not a problem, because FILE_SAME returns true if the two files are
> lexically identical, even if they don't exist, so you get the best of both
> worlds.

Huh! OK.

Craig


--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: relative path from one absolute path to another? [message #49713 is a reply to message #49680] Thu, 10 August 2006 15:33 Go to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Wed, 09 Aug 2006 15:17:15 -0400, Craig Markwardt wrote:
> JD Smith <jdsmith@as.arizona.edu> writes:
>> Does it work for Windows paths (with c:\foo or \\host\foo)?
>
> Sure. Of course, if the drive letter is different, there is no
> possible relative path.

So you explicitly test for and separate out the drive letter and then
prepend it later? I didn't see where you do this (and I don't have any
Windows IDL at hand to test these things).

> Regarding links and FILE_SAME(), I didn't assume the directories
> actually exist on disk. In my case, sometimes the relative path is
> devised before the tree exists, so that assumption would have failed.

It's not a problem, because FILE_SAME returns true if the two files are
lexically identical, even if they don't exist, so you get the best of both
worlds.

JD
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: embedding resources in runtime application
Next Topic: netcdf and hdf together

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:22:02 PDT 2025

Total time taken to generate the page: 0.00583 seconds