Re: FILEPATH, FILE_MKDIR and portability [message #26750] |
Mon, 24 September 2001 05:18 |
weitkamp
Messages: 33 Registered: October 1998
|
Member |
|
|
Thanks for trying on Windows, David. I think this here might be the best way:
IDL> tmpdir = FILEPATH(/TMP,'')
IDL> tmp_subdir = FILEPATH(ROOT=tmpdir, SUBDIRECTORY='subdir', '')
... until word reaches me that it fails on some platform.
Timm
David Fanning <david@dfanning.com> wrote in message news:<MPG.1617c0c052f7733e9896bf@news.frii.com>...
> Timm Weitkamp (weitkamp@esrf.fr) writes:
>
>> Generally using IDL on Unix systems, I thought I'd be nice and try to
>> write my next routine in a way that would allow to run it on other OS
>> families. Now at a certain point in the code, I need to create a
>> scratch subdirectory. In Unix this would be called, say, "/tmp/mydir".
>> Of course in other OSs the name is different. I understand that
>> FILEPATH(/TMP, SUBDIR='mydir', 'myfile') will get me the full path
>> name of a file named "myfile" in such a directory. But to create the
>> directory, I need its name alone.
>>
>> I know that on my Unix or Linux machines, I get a correct result when
>> I do
>>
>> IDL> tmpdir = FILEPATH(/TMP, 'mydir')
>> IDL> FILE_MKDIR, tmpdir
>>
>> But nothing tells me that this will work on just any other operating
>> system, e.g., one that makes a cleaner distinction between files and
>> directories than Unix does. It'd probably work on Windows (though I'd
>> appreciate if someone out there could test and confirm this);
>
> It worked on Windows 2000. The directory is created
> in the the directory pointed to by the TEMP or TMP
> system variables.
>
>> I don't
>> know if it would work on a Mac, and am quite sure it would fail on
>> VMS. So what is the correct general way of creating a directory, if
>> not one that starts with "CASE !VERSION.OS_FAMILY OF ..."?
>
> Don't know. Sometimes there is no way around using
> !Version.
>
>> PS. Also, I wonder if it is a bug or a feature that when using
>> FILEPATH with the keyword TMP, the SUBDIRECTORY keyword does not seem
>> to work:
>>
>> IDL> tmpfile = FILEPATH(/TMP, SUBDIRECTORY='subdir', 'file.dat')
>> IDL> HELP, tmpfile
>> IDL> TMPFILE STRING = '/usr/tmp/file.dat'
>
> Hard to say if it is a bug or feature, but the
> Subdirectory designation does indeed appear to
> be ignored.
>
> Cheers,
>
> David
|
|
|
Re: FILEPATH, FILE_MKDIR and portability [message #26755 is a reply to message #26750] |
Sun, 23 September 2001 09:50  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Timm Weitkamp (weitkamp@esrf.fr) writes:
> Generally using IDL on Unix systems, I thought I'd be nice and try to
> write my next routine in a way that would allow to run it on other OS
> families. Now at a certain point in the code, I need to create a
> scratch subdirectory. In Unix this would be called, say, "/tmp/mydir".
> Of course in other OSs the name is different. I understand that
> FILEPATH(/TMP, SUBDIR='mydir', 'myfile') will get me the full path
> name of a file named "myfile" in such a directory. But to create the
> directory, I need its name alone.
>
> I know that on my Unix or Linux machines, I get a correct result when
> I do
>
> IDL> tmpdir = FILEPATH(/TMP, 'mydir')
> IDL> FILE_MKDIR, tmpdir
>
> But nothing tells me that this will work on just any other operating
> system, e.g., one that makes a cleaner distinction between files and
> directories than Unix does. It'd probably work on Windows (though I'd
> appreciate if someone out there could test and confirm this);
It worked on Windows 2000. The directory is created
in the the directory pointed to by the TEMP or TMP
system variables.
> I don't
> know if it would work on a Mac, and am quite sure it would fail on
> VMS. So what is the correct general way of creating a directory, if
> not one that starts with "CASE !VERSION.OS_FAMILY OF ..."?
Don't know. Sometimes there is no way around using
!Version.
> PS. Also, I wonder if it is a bug or a feature that when using
> FILEPATH with the keyword TMP, the SUBDIRECTORY keyword does not seem
> to work:
>
> IDL> tmpfile = FILEPATH(/TMP, SUBDIRECTORY='subdir', 'file.dat')
> IDL> HELP, tmpfile
> IDL> TMPFILE STRING = '/usr/tmp/file.dat'
Hard to say if it is a bug or feature, but the
Subdirectory designation does indeed appear to
be ignored.
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|