Forum: Ruby FileUtils.ln cross platform?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
45196398e9685000d195ec626d477f0e?d=identicon&s=25 Trans (Guest)
on 2007-06-12 20:52
(Received via mailing list)
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.
Aee77dba395ece0a04c688b05b07cd63?d=identicon&s=25 Daniel Berger (Guest)
on 2007-06-12 22:43
(Received via mailing list)
On Jun 12, 12:51 pm, Trans <transf...@gmail.com> wrote:
>     else
>
> 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
45196398e9685000d195ec626d477f0e?d=identicon&s=25 Trans (Guest)
on 2007-06-13 00:41
(Received via mailing list)
On Jun 12, 4:41 pm, Daniel Berger <djber...@gmail.com> wrote:
> >   # to a copy if the link fails.
> >     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.
Aee77dba395ece0a04c688b05b07cd63?d=identicon&s=25 Daniel Berger (Guest)
on 2007-06-13 16:31
(Received via mailing list)
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/aa363866.aspx

Regards,

Dan
45196398e9685000d195ec626d477f0e?d=identicon&s=25 Trans (Guest)
on 2007-06-14 00:33
(Received via mailing list)
On Jun 13, 10:30 am, Daniel Berger <djber...@gmail.com> wrote:
> > really the same thing. Are you using Vista yet. Do you know?
> http://msdn2.microsoft.com/en-us/library/aa363866.aspx
Yup. You are right.

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

  -- http://msdn2.microsoft.com/en-us/library/aa365680.aspx

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

T.
This topic is locked and can not be replied to.