ftools move bug on Windows

C

Chris Morris

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top