Hello
I’m searching a portable way of copying a file from one directory to
another in ruby. Of course I could open a file for reading, another for
writing, and copy byte per byte, but is there another way ? Or am I
missing something ?
Thanks.
···
–
Florent “flure” C.
Décrypter l’@ pour répondre
Coders don’t die, they just JMP without RET !
Florent ‘flure’ C. wrote:
I’m searching a portable way of copying a file from one directory to
another in ruby. Of course I could open a file for reading, another for
writing, and copy byte per byte, but is there another way ? Or am I
missing something ?
require ‘fileutils’
have a look at
FileUtils.cp
···
–
Simon Strandgaard
Ok, thanks 
So I was missing something ; the FileUtils class isn’t described in the
Pragmatic Programmer’s Guide 
···
Le Mon, 17 May 2004 23:53:04 +0900, Simon Strandgaard a écrit :
require ‘fileutils’
have a look at
FileUtils.cp
–
Florent “flure” C.
Décrypter l’@ pour répondre
Coders don’t die, they just JMP without RET !
require ‘fileutils’
have a look at
FileUtils.cp
Ok, thanks 
So I was missing something ; the FileUtils class isn’t described in the
Pragmatic Programmer’s Guide 
The pickaxe book is unfortunatly quite old.
The RI is a commandline reference tool… with all the goodies from pickaxe,
where everything is uptodate.
http://raa.ruby-lang.org/project/ri/
For instance
ri FileUtils.cp
----------------------------------------------------------- FileUtils#cp
cp(src, dest, options = {})
···
On Tue, 18 May 2004 00:08:53 +0900 “Florent ‘flure’ C.” flurePASDESPAM@freePASDESPAM.fr wrote:
Le Mon, 17 May 2004 23:53:04 +0900, Simon Strandgaard a écrit :
Options: preserve noop verbose
Copies a file +src+ to +dest+. If +dest+ is a directory, copies
+src+ to +dest/src+.
If +src+ is a list of files, then +dest+ must be a directory.
FileUtils.cp 'eval.c', 'eval.c.org'
FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6'
FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6', :verbose => true
(also known as copy)
–
Simon Strandgaard
Simon Strandgaard neoneye@adslhome.dk writes:
[ … ]
The pickaxe book is unfortunatly quite old.
The RI is a commandline reference tool… with all the goodies from pickaxe,
where everything is uptodate.
http://raa.ruby-lang.org/project/ri/
For instance
ri FileUtils.cp
[ … etc. … ]
This sounds like a great tool. I downloaded it and I followed the
installation instructions, with the following result:
% ruby install.rb
install.rb:46:in `=~': type mismatch: String given (TypeError)
from install.rb:46
This is with the following ruby version:
ruby 1.9.0 (2004-04-19) [i386-freebsd4.0]
Perhaps ri is a bit out of date, as well?
···
–
Lloyd Zusman
ljz@asfast.com
God bless you.
That particular project is also old. Downloading it will not inform
you about FileUtils.
‘ri’ is now part of Ruby. See
http://www.rubygarden.org/ruby?NextGenerationRi
for more information, and let me know if there’s anything missing.
Cheers,
Gavin
···
On Tuesday, May 18, 2004, 1:18:42 AM, Simon wrote:
So I was missing something ; the FileUtils class isn’t described in the
Pragmatic Programmer’s Guide 
The pickaxe book is unfortunatly quite old.
The RI is a commandline reference tool… with all the goodies from pickaxe,
where everything is uptodate.
http://raa.ruby-lang.org/project/ri/