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

Home » Public Forums » archive » testing if two strings point to the same file
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
testing if two strings point to the same file [message #94264] Wed, 15 March 2017 15:43 Go to next message
MarioIncandenza is currently offline  MarioIncandenza
Messages: 231
Registered: February 2005
Senior Member
Hello IDL Wizards,

IDL> file1='/tmp/qq/qq.dat'
IDL> file2='/tmp//qq//qq.dat'
IDL> file_copy,file1,file2
% FILE_COPY: Source file must be different from target file.

This situation will only arise if someone has done something dumb, or at least inconsistent. Let he/she who is without sin cast the first stone.

Is there a good way to test if FILE1 and FILE2 are actually the same file?

--Edward H.
Re: testing if two strings point to the same file [message #94265 is a reply to message #94264] Wed, 15 March 2017 15:56 Go to previous messageGo to next message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
On Wednesday, March 15, 2017 at 11:43:13 PM UTC+1, Edward Hyer wrote:
> Hello IDL Wizards,
>
> IDL> file1='/tmp/qq/qq.dat'
> IDL> file2='/tmp//qq//qq.dat'
> IDL> file_copy,file1,file2
> % FILE_COPY: Source file must be different from target file.
>
> This situation will only arise if someone has done something dumb, or at least inconsistent. Let he/she who is without sin cast the first stone.
>
> Is there a good way to test if FILE1 and FILE2 are actually the same file?
>
> --Edward H.

I would try this (it works on windows):

f1_info = file_info(file1)
f2_info = file_info(file2)
if f1_info.name ne f1_info.name then file_copy,file1,file2 $
else print, 'no need to *overselfcopy*'

If you like to keep things short(er):
if (file_info(file1)).name ne (file_info(file2)).name then file_copy,file1,file2

cheers,
Helder
Re: testing if two strings point to the same file [message #94266 is a reply to message #94264] Wed, 15 March 2017 16:42 Go to previous messageGo to next message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
You could also use the /ALLOW_SAME keyword to FILE_COPY. --Wayne

ALLOW_SAME

Attempting to copy a file on top of itself by specifying the same file for SourcePath and DestPath is usually considered to be an error. If the ALLOW_SAME keyword is set, no copying is done and the operation is considered successful.

On Wednesday, March 15, 2017 at 6:43:13 PM UTC-4, Edward Hyer wrote:
> Hello IDL Wizards,
>
> IDL> file1='/tmp/qq/qq.dat'
> IDL> file2='/tmp//qq//qq.dat'
> IDL> file_copy,file1,file2
> % FILE_COPY: Source file must be different from target file.
>
> This situation will only arise if someone has done something dumb, or at least inconsistent. Let he/she who is without sin cast the first stone.
>
> Is there a good way to test if FILE1 and FILE2 are actually the same file?
>
> --Edward H.
Re: testing if two strings point to the same file [message #94267 is a reply to message #94265] Wed, 15 March 2017 16:52 Go to previous messageGo to next message
MarioIncandenza is currently offline  MarioIncandenza
Messages: 231
Registered: February 2005
Senior Member
Thank you for the accurate and speedy answer!
Re: testing if two strings point to the same file [message #94268 is a reply to message #94266] Wed, 15 March 2017 16:52 Go to previous message
MarioIncandenza is currently offline  MarioIncandenza
Messages: 231
Registered: February 2005
Senior Member
> ALLOW_SAME
Another good answer-- thanks!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: JPEG2000 with Floating point data possible?
Next Topic: install instructions for python bridge in 8.5.1 ?

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

Current Time: Wed Oct 08 11:36:28 PDT 2025

Total time taken to generate the page: 0.00478 seconds