Gavin Sinclair
10/8/2003 6:42:00 AM
> All-
>
> On a Windows NT system, is there a way to quickly delete directories
> (from within a Ruby script) that may have read-only files in them. The
> command I've been using is
>
> File.delete(*Dir["*.*"])
>
> but this crashes when it hits a RO file.
>
> Similarly, is there a way to force the overwriting of a RO file? I've
> been using File.syscopy, but this, too, crashes when attempting to
> overwrite an RO file.
>
> Thanks!
>
> -Kurt Euler
Try the standard library file 'fileutils.rb'. You can RDoc the file to
see some documentation or (of course) look at the file directly.
From memory:
require 'fileutils'
FileUtils.rm_rf(directory) # trash a directory tree
FileUtils.cp(src, dest, :force => true) # copy over a RO file
These use Unix names, but I imagine it will work on Windows.
Gavin