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

Home » Public Forums » archive » Re: FILE_DIRNAME question
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: FILE_DIRNAME question [message #45601] Mon, 19 September 2005 17:21
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Kenneth P. Bowman writes:

> So, how does everyone assemble a platform-independent path from an array
> of directory names?

I use FILEPATH. I'm pretty sure it's not obsolete. At least
if it is, it just confirms that I am too, since I use it
every day. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: FILE_DIRNAME question [message #45602 is a reply to message #45601] Mon, 19 September 2005 14:24 Go to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Mon, 19 Sep 2005 12:43:02 -0500, Kenneth Bowman wrote:

> Can anyone explain what I am doing wrong here?
>
> IDL> print, FILE_DIRNAME(['top', 'middle'], /MARK)
> ./ ./
> IDL> print, FILE_DIRNAME('/top/middle/', /MARK)
> /top/

Ummm, nothing? The first one has two relative file names, so their
directory is the current directory, aka ".", or "./" when you are
using /MARK. Maybe you meant:

IDL> print, filepath(ROOT='top','middle')
top/middle

JD
Re: FILE_DIRNAME question [message #45603 is a reply to message #45602] Mon, 19 September 2005 13:38 Go to previous message
btt is currently offline  btt
Messages: 345
Registered: December 2000
Senior Member
Kenneth Bowman wrote:
> Can anyone explain what I am doing wrong here?
>
> IDL> print, FILE_DIRNAME(['top', 'middle'], /MARK)
> ./ ./
> IDL> print, FILE_DIRNAME('/top/middle/', /MARK)
> /top/
>
>

Hi,

I have the same system and version. I'm not sure what to think, but I
wonder why you are comparing '/top...' with 'top'. I have always
assumed that the leading '/' was an important component of the path
description. At least when I do the following I get what I expect to get.

IDL> print, FILE_DIRNAME(['/top', '/middle'], /MARK)
/ /

Ben
Re: FILE_DIRNAME question [message #45604 is a reply to message #45603] Mon, 19 September 2005 13:08 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Kenneth Bowman writes:

> Can anyone explain what I am doing wrong here?
>
> IDL> print, FILE_DIRNAME(['top', 'middle'], /MARK)
> ./ ./
> IDL> print, FILE_DIRNAME('/top/middle/', /MARK)
> /top/

No, I can't explain it, because I don't understand it.
I mucked around with it for awhile, then wrote my own,
which was more convenient for me, too, because I could
obtain the base filename, the directory name, and the file
extension all at once.

http://www.dfanning.com/programs/fsc_base_filename.pro

It works like this:

filename = '/top/middle/myfile.jpg'
b = FSC_Base_Filename(filename, Directory=d, Extension=)
Print, 'Directory: ', d
Print, 'Filename: ', b
Print, 'Extension: ', e

Or, in an IDL session.

IDL> filename = '/top/middle/myfile.jpg'
IDL> b = FSC_Base_Filename(filename, Directory=d, $
IDL> Extension=e, Path_Sep='/')
IDL> Print, 'Directory: ', d
Directory: /top/middle/
IDL> Print, 'Filename: ', b
Filename: myfile
IDL> Print, 'Extension: ', e
Extension: jpg

Or, as in your example:

IDL> filename = '/top/middle/'
IDL> b = FSC_Base_Filename(filename, Directory=d, $
IDL> Extension=e, Path_Sep='/')
IDL> Print, 'Directory: ', d
Directory: /top/middle/
IDL> Print, 'Filename: ', b
Filename:
IDL> Print, 'Extension: ', e
Extension:


The path separator is returned by PATH_SEP, but if you want to
make separate a UNIX path on a Windows machine, or visa versa,
you can specify what the path separator should be via a keyword.

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: FILE_DIRNAME question [message #45605 is a reply to message #45602] Mon, 19 September 2005 16:44 Go to previous message
Kenneth P. Bowman is currently offline  Kenneth P. Bowman
Messages: 585
Registered: May 2000
Senior Member
In article <pan.2005.09.19.21.24.55.124175@as.arizona.edu>,
JD Smith <jdsmith@as.arizona.edu> wrote:

> On Mon, 19 Sep 2005 12:43:02 -0500, Kenneth Bowman wrote:
>
>> Can anyone explain what I am doing wrong here?
>>
>> IDL> print, FILE_DIRNAME(['top', 'middle'], /MARK)
>> ./ ./
>> IDL> print, FILE_DIRNAME('/top/middle/', /MARK)
>> /top/
>
> Ummm, nothing? The first one has two relative file names, so their
> directory is the current directory, aka ".", or "./" when you are
> using /MARK. Maybe you meant:
>
> IDL> print, filepath(ROOT='top','middle')
> top/middle
>
> JD

Ah well, I have never have been able to make sense of the documentation
for most of the FILE_ routines. I thought FILEPATH was obsolescent,
like FINDFILE. I guess it was the consistent procedure naming
convention that threw me. ;-)

So, how does everyone assemble a platform-independent path from an array
of directory names?

Ken
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Container/Holder Destruction
Next Topic: wildcard in "where" command

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

Current Time: Wed Oct 08 15:14:24 PDT 2025

Total time taken to generate the page: 0.01111 seconds