Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > FileUtils in widows

Reply
Thread Tools

FileUtils in widows

 
 
Jonathan Dale
Guest
Posts: n/a
 
      07-28-2007
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-forum.com/.

 
Reply With Quote
 
 
 
 
William James
Guest
Posts: n/a
 
      07-28-2007
On Jul 28, 5:03 pm, Jonathan Dale <(E-Mail Removed)> 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




 
Reply With Quote
 
 
 
 
Jon Dale
Guest
Posts: n/a
 
      07-28-2007
>> 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-forum.com/.

 
Reply With Quote
 
Gavin Sinclair
Guest
Posts: n/a
 
      07-28-2007
On Jul 29, 8:24 am, Jon Dale <(E-Mail Removed)> 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)

 
Reply With Quote
 
Jon Dale
Guest
Posts: n/a
 
      07-29-2007
Gavin Sinclair wrote:
> On Jul 29, 8:24 am, Jon Dale <(E-Mail Removed)> 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-forum.com/.

 
Reply With Quote
 
William James
Guest
Posts: n/a
 
      07-29-2007
On Jul 28, 6:58 pm, Gavin Sinclair <(E-Mail Removed)> wrote:
> On Jul 29, 8:24 am, Jon Dale <(E-Mail Removed)> 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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Widows XP Home.... =?Utf-8?B?am9uaQ==?= Microsoft Certification 1 03-28-2006 03:02 AM
Widows Service Event for LogOff tariq_swl ASP .Net 0 10-01-2005 06:15 AM
Parent widows refresh Peter ASP .Net 4 07-26-2005 06:10 PM
Files appearing in reverse alpabetical order in folder widows and save ans open dialog boxes. WIN98SE nemo Computer Support 5 01-20-2004 02:07 PM
Widows Question (XP) Bay0Wulf Computer Support 4 12-01-2003 06:50 PM



Advertisments