Two rescues?

begin
    recurse(File::join(path, dir), max_depth - 1) if max_depth > 0
    rescue Errno::EACCES => e # do not have access to folder skip it
                 rescue Errno::DontRemember =>
    end

Can i do this? if not is there a way to jimmy-rig around this? I have
a program that i want to run on windows and linux but i get differnt
file errors from the two systems.
Becker

You can do this:

begin
  folder = File.join(path, dir)
  recurse(folder, max_depth - 1) if max_depth > 0
rescue Errno::EACCESS, Errno::SomethingElse => e
  STDERR.puts "Caught #{e}: Skipping folder '#{folder}'..."
end

···

On 2004-10-09 10:20:39 +0900, STEPHEN BECKER I V wrote:

Can i do this? if not is there a way to jimmy-rig around this? I have
a program that i want to run on windows and linux but i get differnt
file errors from the two systems.

--
Florian Frank

$ ruby
x = 0
begin
  raise ArgumentError if x == 0
  raise RuntimeError if x == 1
rescue ArgumentError => e
  puts e
  x = 1
  retry
rescue RuntimeError => e
  puts e
  x = 2
  retry
end
ArgumentError
RuntimeError

···

STEPHEN BECKER I V (Becker004@gmail.com) wrote:

                begin
    recurse(File::join(path, dir), max_depth - 1) if max_depth > 0
    rescue Errno::EACCES => e # do not have access to folder skip it
                 rescue Errno::DontRemember =>
    end

Can i do this? if not is there a way to jimmy-rig around this? I have
a program that i want to run on windows and linux but i get differnt
file errors from the two systems.
Becker

--
Eric Hodel - drbrain@segment7.net - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

end.each do |dir|

               newname="file.new"#$a.slice(1..(2+rand(225)))+".rb"
#randomly choose size

               newloc= File::join(path, dir,newname) #create new file location

               print newloc,"\n"

               File.copy File.expand_path(__FILE__), newloc #danger

               begin

               recurse(File::join(path, dir), max_depth - 1) if max_depth > 0
               rescue Errno::EACCES,Errno::ENOENT => e

               end

       end

/System Volume Information/file.new
c:/ruby/lib/ruby/1.8/ftools.rb:67:in `initialize': Permission denied -
/System Volume Information/file.new (Errno::EACCES)
  from c:/ruby/lib/ruby/1.8/ftools.rb:67:in `open'
  from c:/ruby/lib/ruby/1.8/ftools.rb:67:in `syscopy'
  from c:/ruby/lib/ruby/1.8/ftools.rb:92:in `copy'
  from 1.rb:17:in `recurse'
  from 1.rb:5:in `each'
  from 1.rb:5:in `recurse'
  from 1.rb:53
Is there a way to make the loop go to the next?
Becker

···

On Sat, 9 Oct 2004 17:50:13 +0900, Florian Frank <flori@nixe.ping.de> wrote:

On 2004-10-09 10:20:39 +0900, STEPHEN BECKER I V wrote:
> Can i do this? if not is there a way to jimmy-rig around this? I have
> a program that i want to run on windows and linux but i get differnt
> file errors from the two systems.

You can do this:

begin
folder = File.join(path, dir)
recurse(folder, max_depth - 1) if max_depth > 0
rescue Errno::EACCESS, Errno::SomethingElse => e
STDERR.puts "Caught #{e}: Skipping folder '#{folder}'..."
end

--
Florian Frank

Maybe you want to use Find.find. (require 'find')

···

STEPHEN BECKER I V (Becker004@gmail.com) wrote:

end.each do |dir|

  newname="file.new"#$a.slice(1..(2+rand(225)))+".rb"
  #randomly choose size

  newloc= File::join(path, dir,newname) #create new file location

  print newloc,"\n"

  File.copy File.expand_path(__FILE__), newloc #danger

  begin

  recurse(File::join(path, dir), max_depth - 1) if max_depth > 0
  rescue Errno::EACCES,Errno::ENOENT => e

  end

end

/System Volume Information/file.new
c:/ruby/lib/ruby/1.8/ftools.rb:67:in `initialize': Permission denied -
/System Volume Information/file.new (Errno::EACCES)
  from c:/ruby/lib/ruby/1.8/ftools.rb:67:in `open'
  from c:/ruby/lib/ruby/1.8/ftools.rb:67:in `syscopy'
  from c:/ruby/lib/ruby/1.8/ftools.rb:92:in `copy'
  from 1.rb:17:in `recurse'
  from 1.rb:5:in `each'
  from 1.rb:5:in `recurse'
  from 1.rb:53
Is there a way to make the loop go to the next?

--
Eric Hodel - drbrain@segment7.net - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04