FILEPATH, FILE_MKDIR and portability [message #26761] |
Sat, 22 September 2001 07:12 |
weitkamp
Messages: 33 Registered: October 1998
|
Member |
|
|
Dear people,
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); 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 ..."?
Thanks,
Timm
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'
--
Timm Weitkamp
European Synchrotron Radiation Facility (ESRF), Grenoble, France
Phone: (+33) (0) 4 76 88 28 86 E-mail: weitkamp@esrf.fr
|
|
|