[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

FileUtils.ln cross platform?

Trans

6/12/2007 6:51:00 PM

What happens when you use FileUtils.ln on a Windows system. Does it
fail? Is that why Jim Weirich uses #safe_ln, eg.

LINKING_SUPPORTED = [true]

# Attempt to do a normal file link, but fall back
# to a copy if the link fails.
def safe_ln(*args)
unless LINKING_SUPPORTED[0]
cp(*args)
else
begin
ln(*args)
rescue Errno::EOPNOTSUPP
LINKING_SUPPORTED[0] = false
cp(*args)
end
end
end

If so, is there a better way? Or why wouldn't this be built into Ruby.

Thanks,
T.


6 Answers

Daniel Berger

6/12/2007 8:42:00 PM

0



On Jun 12, 12:51 pm, Trans <transf...@gmail.com> wrote:
> What happens when you use FileUtils.ln on a Windows system. Does it
> fail? Is that why Jim Weirich uses #safe_ln, eg.
>
> LINKING_SUPPORTED = [true]
>
> # Attempt to do a normal file link, but fall back
> # to a copy if the link fails.
> def safe_ln(*args)
> unless LINKING_SUPPORTED[0]
> cp(*args)
> else
> begin
> ln(*args)
> rescue Errno::EOPNOTSUPP
> LINKING_SUPPORTED[0] = false
> cp(*args)
> end
> end
> end
>
> If so, is there a better way? Or why wouldn't this be built into Ruby.
>
> Thanks,
> T.

With 1.8.5 FileUtils.ln simply copied the file. Without digging into
changelogs, I can only speculate that it may have been an unsupported
op in earlier versions of Ruby, and that's why Jim added extra code.

Note that with the advent of Vista the issue of symlinks on Windows
will need to be revisited.

Regards,

Dan


Trans

6/12/2007 10:41:00 PM

0



On Jun 12, 4:41 pm, Daniel Berger <djber...@gmail.com> wrote:
> On Jun 12, 12:51 pm, Trans <transf...@gmail.com> wrote:
>
>
>
> > What happens when you use FileUtils.ln on a Windows system. Does it
> > fail? Is that why Jim Weirich uses #safe_ln, eg.
>
> > LINKING_SUPPORTED = [true]
>
> > # Attempt to do a normal file link, but fall back
> > # to a copy if the link fails.
> > def safe_ln(*args)
> > unless LINKING_SUPPORTED[0]
> > cp(*args)
> > else
> > begin
> > ln(*args)
> > rescue Errno::EOPNOTSUPP
> > LINKING_SUPPORTED[0] = false
> > cp(*args)
> > end
> > end
> > end
>
> > If so, is there a better way? Or why wouldn't this be built into Ruby.
>
> > Thanks,
> > T.
>
> With 1.8.5 FileUtils.ln simply copied the file. Without digging into
> changelogs, I can only speculate that it may have been an unsupported
> op in earlier versions of Ruby, and that's why Jim added extra code.

Excellent. Glad I don;t have to mess with it. Thanks Dan!

> Note that with the advent of Vista the issue of symlinks on Windows
> will need to be revisited.

Indeed. I heard it supports them, but later heard that they aren't
really the same thing. Are you using Vista yet. Do you know?

T.


Daniel Berger

6/13/2007 2:27:00 PM

0

On Jun 12, 4:41 pm, Trans <transf...@gmail.com> wrote:
> On Jun 12, 4:41 pm, Daniel Berger <djber...@gmail.com> wrote:

<snip>

> > Note that with the advent of Vista the issue of symlinks on Windows
> > will need to be revisited.
>
> Indeed. I heard it supports them, but later heard that they aren't
> really the same thing. Are you using Vista yet. Do you know?
>
> T.- Hide quoted text -

I don't have Vista yet. I'm waiting until Leopard is released, at
which point I'll setup a dual boot config on my Mac tower. Hopefully,
SP 1 will be out by then.

As for whether or not they're the same thing, the docs for
CreateSymbolicLink() sure seem to indicate they are:

http://msdn2.microsoft.com/en-us/library/aa3...

Regards,

Dan


Trans

6/13/2007 10:33:00 PM

0



On Jun 13, 10:30 am, Daniel Berger <djber...@gmail.com> wrote:
> On Jun 12, 4:41 pm, Trans <transf...@gmail.com> wrote:
>
> > On Jun 12, 4:41 pm, Daniel Berger <djber...@gmail.com> wrote:
>
> <snip>
>
> > > Note that with the advent of Vista the issue of symlinks on Windows
> > > will need to be revisited.
>
> > Indeed. I heard it supports them, but later heard that they aren't
> > really the same thing. Are you using Vista yet. Do you know?
>
> > T.- Hide quoted text -
>
> I don't have Vista yet. I'm waiting until Leopard is released, at
> which point I'll setup a dual boot config on my Mac tower. Hopefully,
> SP 1 will be out by then.
>
> As for whether or not they're the same thing, the docs for
> CreateSymbolicLink() sure seem to indicate they are:
>
> http://msdn2.microsoft.com/en-us/library/aa3...

Yup. You are right.

"Microsoft has implemented its symbolic links to function just like
UNIX links."

-- http://msdn2.microsoft.com/en-us/library/aa3...

Somewhere I picked up some bad info. Thanks for setting me straight.

T.


fformby

1/16/2010 10:23:00 PM

0

On Sat, 16 Jan 2010 22:58:45 +0100, The Foreskin Peeler
<peelingtheforeskin@sick.admin> wrote:

>On Sat, 16 Jan 2010 06:16:11 GMT, The Revd wrote:
>
>> On Sat, 16 Jan 2010 18:50:49 +1300, "Tilly" <paul1952@gmail.com>
>> wrote:
>>
>>>
>>>A veteran Iranian diplomat based in Norway has resigned from his post,
>>>denounced his government and urged colleagues around the world to do the
>>>same after the regime's brutal suppression of huge opposition demonstrations
>>>last month.
>>>
>>>Mohammed-Reza Heydari, Iran's consul in Oslo, is the first Iranian diplomat
>>>to publicly quit and condemn the regime. He revealed that it sought to lure
>>>him back to Tehran after rumors of his defection surfaced last week. At the
>>>time, the Iranian Foreign Ministry insisted that the rumors were baseless.
>>>
>>>In an interview with the Norwegian television channel NRK, Heydari said that
>>>he decided to resign after Iranian security forces killed a dozen
>>>demonstrators on Dec. 27.
>>>
>>>"I hope my friends and colleagues in other parts of the world who see and
>>>hear me now and know me will move in the same direction as their people. I
>>>hope they will manage to sacrifice some personal interests and rather think
>>>of what is in the interest of their people and their nation," he said.
>>>
>>>Heydari said that he did not fear for his life, but in the past the regime
>>>has arrested the relatives of those, such as Shirin Ebadi, the Nobel peace
>>>laureate, who criticize it from abroad. Opposition Web sites said that
>>>Heydari's brother was a well-known Iranian television presenter
>>>
>>>The Times Of London.
>>
>> What exactly does this have to do with jews, twatty?
>
>What do you have to do with ANYTHING, psycho?

WE ask the questions, Grik cocksucker.

<Very Bugger Grease>

The Peeler

1/16/2010 10:59:00 PM

0

On Sat, 16 Jan 2010 22:23:24 GMT, The Revd wrote:

> On Sat, 16 Jan 2010 22:58:45 +0100, The Foreskin Peeler
> <peelingtheforeskin@sick.admin> wrote:
>
>>On Sat, 16 Jan 2010 06:16:11 GMT, The Revd wrote:
>>
>>> On Sat, 16 Jan 2010 18:50:49 +1300, "Tilly" <paul1952@gmail.com>
>>> wrote:
>>>
>>>>
>>>>A veteran Iranian diplomat based in Norway has resigned from his post,
>>>>denounced his government and urged colleagues around the world to do the
>>>>same after the regime's brutal suppression of huge opposition demonstrations
>>>>last month.
>>>>
>>>>Mohammed-Reza Heydari, Iran's consul in Oslo, is the first Iranian diplomat
>>>>to publicly quit and condemn the regime. He revealed that it sought to lure
>>>>him back to Tehran after rumors of his defection surfaced last week. At the
>>>>time, the Iranian Foreign Ministry insisted that the rumors were baseless.
>>>>
>>>>In an interview with the Norwegian television channel NRK, Heydari said that
>>>>he decided to resign after Iranian security forces killed a dozen
>>>>demonstrators on Dec. 27.
>>>>
>>>>"I hope my friends and colleagues in other parts of the world who see and
>>>>hear me now and know me will move in the same direction as their people. I
>>>>hope they will manage to sacrifice some personal interests and rather think
>>>>of what is in the interest of their people and their nation," he said.
>>>>
>>>>Heydari said that he did not fear for his life, but in the past the regime
>>>>has arrested the relatives of those, such as Shirin Ebadi, the Nobel peace
>>>>laureate, who criticize it from abroad. Opposition Web sites said that
>>>>Heydari's brother was a well-known Iranian television presenter
>>>>
>>>>The Times Of London.
>>>
>>> What exactly does this have to do with jews, twatty?
>>
>>What do you have to do with ANYTHING, psycho?
>
> WE ask the questions, Grik cocksucker.
>
> <Very Bugger Grease>

YOU just get your bleeding psychopathic ass clobbered here, EVERY DAY, you
bleeding psycho! <G>