[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

FileUtils in widows

Jonathan Dale

7/28/2007 10:04:00 PM

I am fairly new to ruby and am working with windows xp. I'm trying to
copy files from one directory to another using the FileUtils module.
When I run the program, I get a Permission Denied error (EACCES). Any
thoughts on how to get this to work?

files.each do |f|
next if f == "." or f == ".."
FileUtils.copy(dir,newdir)
end

Thanks in advance for any help.

jjd
--
Posted via http://www.ruby-....

5 Answers

William James

7/28/2007 10:11:00 PM

0

On Jul 28, 5:03 pm, Jonathan Dale <jdal...@yahoo.com> wrote:
> I am fairly new to ruby and am working with windows xp. I'm trying to
> copy files from one directory to another using the FileUtils module.
> When I run the program, I get a Permission Denied error (EACCES). Any
> thoughts on how to get this to work?
>
> files.each do |f|
> next if f == "." or f == ".."
> FileUtils.copy(dir,newdir)

You forgot to use f in this line.

> end



Jonathan Dale

7/28/2007 10:24:00 PM

0

>> files.each do |f|
>> next if f == "." or f == ".."
>> FileUtils.copy(dir,newdir)
>
> You forgot to use f in this line.

Isn't the f covered in the do statement? I'm not sure how else f would
be implemented.
--
Posted via http://www.ruby-....

Gavin Sinclair

7/28/2007 11:58:00 PM

0

On Jul 29, 8:24 am, Jon Dale <jdal...@yahoo.com> wrote:
> >> files.each do |f|
> >> next if f == "." or f == ".."
> >> FileUtils.copy(dir,newdir)
>
> > You forgot to use f in this line.
>
> Isn't the f covered in the do statement? I'm not sure how else f would
> be implemented.

FileUtils.copy(f, newdir)

Jonathan Dale

7/29/2007 12:44:00 AM

0

Gavin Sinclair wrote:
> On Jul 29, 8:24 am, Jon Dale <jdal...@yahoo.com> wrote:
>> >> files.each do |f|
>> >> next if f == "." or f == ".."
>> >> FileUtils.copy(dir,newdir)
>>
>> > You forgot to use f in this line.
>>

>
> FileUtils.copy(f, newdir)

Thanks, works now. I stared at it so long I couldn't see the obvious!
--
Posted via http://www.ruby-....

William James

7/29/2007 12:45:00 AM

0

On Jul 28, 6:58 pm, Gavin Sinclair <gsincl...@gmail.com> wrote:
> On Jul 29, 8:24 am, Jon Dale <jdal...@yahoo.com> wrote:
>
> > >> files.each do |f|
> > >> next if f == "." or f == ".."
> > >> FileUtils.copy(dir,newdir)
>
> > > You forgot to use f in this line.
>
> > Isn't the f covered in the do statement? I'm not sure how else f would
> > be implemented.
>
> FileUtils.copy(f, newdir)

Or
FileUtils.copy( "#{dir}/#{f}", newdir)

FileUtils.copy isn't a mind-reader.
It doesn't know (or assume) that you have put
the name of the file in variable named f.
It doesn't know that it is being invoked
inside of a loop.