From: Joe Mason Date: 2004-03-16T15:59:34+09:00 Subject: Re: How can I copy a read-only file? In article , Curt Hibbs wrote: > I've got a generic method that copies files. I want to preserve the > attributes of the source file in the destination file. I started using this: > > require "ftools" > ... > File.copy(src_file, dest_dir) > > This works until I encounter a read-only file, then I get an exception: > > c:/ruby/lib/ruby/1.8/ftools.rb:23:in `initialize': > Permission denied - E:\Dev\RubyDev\rubyinstaller\c > vs-repo\installer\stable/doc\DBD/ODBC-0.96/COPYING > (Errno::EACCES) Yes. That's because you don't have permission to read it, as expected. > So, how do you copy read-only files in ruby? You can't. That's what read-only means. Try it at the command prompt, you won't be able to copy it there, either. I believe you have to chmod it first, then chmod it back. Assuming you're the owner. Joe