Re: Copying files in IDL [message #31190] |
Thu, 20 June 2002 00:14  |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Marc Schellens wrote:
>
> Reimar Bauer wrote:
>>
>> Sean Raffuse wrote:
>>>
>>> Hello folks. I would like to make a copy of an hdf file, changing only to
>>> filename and the content of one of datasets in the hdf. I have no problem
>>> putting in the new content, but this overwrites the old file, which I need
>>> to preserve. How do I copy and/or rename the file in IDL? I don't want to
>>> have to rebuild the entire hdf file and it's dozens of attributes. Just a
>>> near exact copy with a different name.
>>>
>>> Thanks in advance,
>>>
>>> Sean
>>
>> Dear Sean,
>>
>> what's with this primitive way.
>>
>> spawn,'cp file.hdf new_file.hdf'
>>
>> and then operations on then new file.
>>
>> regards
>
> The disadvantage of this solution is that it's not portable.
> If the filesize is not to large, you can do something like:
>
> openr,1,'file.hdf'
> fs=fstat(1)
> b=bytarr(fs.size)
> readu,1,b
> close,1
> openw,1,'new_file.hdf'
> writeu,1,b
> close,1
>
> cheers,
> marc
Then we should do a feature request for file_copy
probably using this routine with /GET_LUN.
If bytarr is replaced with b=make_array(/nozero,ft.size,/byte)
the routine is much faster if filesize is big.
One problem could occure if HDF file size is very large.
Because data is named and index sequentiell organized in this file
and there is no reason by reading/writing with HDF commands
of the whole file at once.
HDF filesize could be bigger than 1 or 10 Giga Byte .
In this case a system command will be better and
you can do a case depending of !version.os_family.
regards
Reimar
--
Reimar Bauer
Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
============================================================ =======
|
|
|