What's a canonical way to copy a file?

It's easy to copy a file with File#{open,read,write}, but I'm
surprised there isn't a prepackaged (OS-independent) API for it like
Perl's File::Copy. I've haven't found any solutions in ri, Pickaxe II
or the RAA. Have I missed something?

Cheers,

Jeremy Henty

You get more with Ruby's FileUtils (comes with standard Ruby since 1.8.0):

    require 'fileutils'
    FileUtils.cp "source", "target"

For a list of all methods with documentation:

    % ri FileUtils

HTH,
  Stefan

···

On Saturday 23 July 2005 10:35, Jeremy Henty wrote:

It's easy to copy a file with File#{open,read,write}, but I'm
surprised there isn't a prepackaged (OS-independent) API for it like
Perl's File::Copy. I've haven't found any solutions in ri, Pickaxe II
or the RAA. Have I missed something?

Cheers,

Jeremy Henty

.... which *is* documented in Pickaxe II. Somehow I missed it. D'oh!
Sorry folks, I'll look more carefully in future. Thanks Stefan,
that's exactly what I was thinking of.

Cheers,

Jeremy

···

In article <200507231046.59272.langstefan@gmx.at>, Stefan Lang wrote:

On Saturday 23 July 2005 10:35, Jeremy Henty wrote:

It's easy to copy a file with File#{open,read,write}, but I'm
surprised there isn't a prepackaged (OS-independent) API for it

You get more with Ruby's FileUtils