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

Home » Public Forums » archive » cd to nonexistent directory and up again
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: cd to nonexistent directory and up again [message #81792 is a reply to message #81708] Wed, 17 October 2012 06:05 Go to previous message
tom.grydeland is currently offline  tom.grydeland
Messages: 51
Registered: September 2012
Member
On Tuesday, October 16, 2012 12:33:19 PM UTC+2, tom.gr...@gmail.com wrote:

> I am using CD to determine whether a given path exists as a directory, and I was expecting the second case to fail just like the first one does, since there is no difference between them in my mind.

Thanks to all those who replied, but I am afraid you're not touching upon my question. I am sorry I have not made my point clearly enough.

1) In a world where directories can be symbolically linked, it is not necessarily true that './bobo/...' is equal to '.', even when 'bobo' exists. Truncating away 'bobo/..' on the assumption that they are the same is arguably incorrect, but it is certainly confusing if it is done in some cases and not in others!

2) In the regular Unix shells, 'ls -ld bobo/..' and 'ls -ld ./bobo/..' both fail, with the error message that the file or directory does not exist.

3) FILE_TEST shows the same strange difference between 'bobo/..' and './bobo/..':

IDL> print, file_test('./bobo/..', /dir)
1
IDL> print, file_test('bobo/..', /dir)
0

It looks like I will have to do what I was hoping to avoid:

1) given a path like 'foo/bar/baz/../quux/..', use file_test(x, /dir) on every sub-path x:
file_test('foo', /dir)
file_test('foo/bar', /dir)
file_test('foo/bar/baz', /dir)
file_test('foo/bar/baz/..', /dir)
file_test('foo/bar/baz/../quux', /dir)
file_test('foo/bar/baz/../quux/..', /dir)

If IDL cannot be relied upon to fail in the next step when one or more of these path components don't exist, then I must test every one of them.

2) If all of these tests pass, then

cd 'foo/bar/baz/../quux/..', curr=old
cd, old, curr=pwd

3) pwd is now the fully-qualified path to the directory indicated by 'foo/bar/baz/../quux/..'


Cheers,

Tom
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Transparent Image Overlays
Next Topic: Dialog_Pickfile Whack-a-Mole

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

Current Time: Sun Oct 12 01:28:38 PDT 2025

Total time taken to generate the page: 1.52252 seconds