ftools move bug on Windows

Discussion in 'Ruby' started by Chris Morris, Aug 7, 2003.

  1. Chris Morris

    Chris Morris Guest

    ftools.rb
    #########
    def move from, to, verbose = false
    to = catname(from, to)
    $deferr.print from, " -> ", to, "\n" if verbose

    if RUBY_PLATFORM =~ /djgpp|(cyg|ms|bcc)win|mingw/ and FileTest.file? to
    unlink to
    end
    fstat = stat(from)
    begin
    rename from, to
    rescue
    begin
    symlink File.readlink(from), to and unlink from
    rescue
    from_stat = stat(from)
    syscopy from, to and unlink from
    utime(from_stat.atime, from_stat.mtime, to)
    begin
    chown(fstat.uid, fstat.gid, to)
    rescue
    end
    end
    end
    end

    If the rename call fails for something like "Permission denied" -- then
    the rescue clause tries to do a .readlink which is not supported on
    Windows. Ruby raises that error, and the original exception is hidden.
    I'm guessing a fix would be to do a platform regex like earlier in the
    method and not attempt the link related items if on Windows, etc.

    Workaround is just to use File.rename instead.

    --

    Chris
    http://clabs.org/blogki
     
    Chris Morris, Aug 7, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eduardo78
    Replies:
    0
    Views:
    265
    Eduardo78
    Nov 3, 2005
  2. Andrew Tomazos
    Replies:
    2
    Views:
    649
    Nobody
    Dec 12, 2011
  3. Wes Gamble
    Replies:
    3
    Views:
    111
    ebeard
    Nov 14, 2006
  4. Replies:
    3
    Views:
    115
    Eric Hodel
    Jul 18, 2008
  5. Daniel
    Replies:
    21
    Views:
    436
    Balog Pal
    May 28, 2013
Loading...

Share This Page