From: Robert Klemme Date: 2004-03-16T18:24:40+09:00 Subject: Re: How can I copy a read-only file? "Joe Mason" schrieb im Newsbeitrag news:slrnc5d6mm.b35.joe@gate.notcharles.ca... > 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. ??? "Read only" means you can *only* read it, but not write it. Obviously you *can* copy read only files, but you can't write to a read only file. Although often you can first delete a read only file you want to write to and then write a new file with the same name. robert