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

Home » Public Forums » archive » Re: cd to nonexistent directory and up again
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
Re: cd to nonexistent directory and up again [message #81702] Tue, 16 October 2012 06:31
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Paul van Delst writes:

> D'oh! FILE_TEST!! I *knew* there was a simpler way!
>
> Thanks!
>
> To the OP: ignore my reply!

I was thinking as I read your earlier post that someone
*really* needs to put together a "Best Practices" web
page. Goodness, people do things in strange ways! ;-)

Cheers,

David

P.S. Of course, this would mean completely banning
the TV command. How far do you think we could get
with that campaign in the astronomy community?

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thue. ("Perhaps thos speakest truth.")
Re: cd to nonexistent directory and up again [message #81703 is a reply to message #81702] Tue, 16 October 2012 06:13 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
On 10/16/12 07:42, fawltylanguage@gmail.com wrote:
> On Tuesday, October 16, 2012 12:33:19 PM UTC+2, tom.gr...@gmail.com wrote:
>
> Both CD's are cd to the current directory, IDL or the underlying OS may optimize it away.
>
> Use file_test('bobo', /dir) instead.

D'oh! FILE_TEST!! I *knew* there was a simpler way!

Thanks!

To the OP: ignore my reply!

cheers,

paulv
Re: cd to nonexistent directory and up again [message #81704 is a reply to message #81703] Tue, 16 October 2012 05:55 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
On 10/16/12 06:33, tom.grydeland@gmail.com wrote:
> Why is it that this fails:
>
>
> IDL> cd, 'bobo/..' % CD: Unable to change current directory to
> bobo/... No such file or directory
>
> but this does not:
>
> IDL> cd, './bobo/..' IDL>
>
>
> 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.

This is (slightly) tangential...

Why not use "FILE_SEARCH" to determine path existence? E.g. from one of
my procedures:

dir_list = FILE_SEARCH("Example*", COUNT=n_dirs)
IF ( n_dirs EQ 0 ) THEN $
MESSAGE, 'No "Example*" directories found!'

And, if the possibility of files being confused for directories is
likely, you can then use the FILE_INFO() function to determine which
elements of the above "dir_list" are actual directories, e.g.

IDL> dir_list = FILE_SEARCH("*", COUNT=n_dirs)
IDL> dir_info = FILE_INFO(dir_list)
IDL> help, dir_info.directory
<Expression> BYTE = Array[11]
IDL> print, dir_info.directory
1 1 1 1 1 1 1 1 1 0 0

First 9 entries in "dir_list" are directories, last two are not.

cheers,

paulv
Re: cd to nonexistent directory and up again [message #81707 is a reply to message #81704] Tue, 16 October 2012 04:42 Go to previous message
Lajos Foldy is currently offline  Lajos Foldy
Messages: 176
Registered: December 2011
Senior Member
On Tuesday, October 16, 2012 12:33:19 PM UTC+2, tom.gr...@gmail.com wrote:
> Why is it that this fails:
>
>
>
>
>
> IDL> cd, 'bobo/..'
>
> % CD: Unable to change current directory to bobo/...
>
> No such file or directory
>
>
>
> but this does not:
>
>
>
> IDL> cd, './bobo/..'
>
> IDL>
>
>
>
>
>
> 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.
>
>
>
> Cheers,
>
>
>
> Tom

Both CD's are cd to the current directory, IDL or the underlying OS may optimize it away.

Use file_test('bobo', /dir) instead.

regards,
Lajos
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: About duration of run process
Next Topic: Re: Surface/shade_surf problem on IDL 7.1 / Lion OS ??

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

Current Time: Wed Oct 08 19:42:26 PDT 2025

Total time taken to generate the page: 0.00628 seconds