From: John Date: 2008-04-26T04:05:09+09:00 Subject: Re: pretty folder tree script > Something like this should work: > > # Implement this properly > def html_escape(s) > s > end Why are we escaping html? It's just a list of file names, after all. > > def recurse_dir(dirname) > Dir.entries(dirname).sort.each do |filename| > if FileTest.directory? filename > puts "
" > puts "
#{html_escape(filename)}
" > recurse_dir(filename) > puts "
" > elsif FileTest.file? filename > puts "#{html_escape(filename)}" > end > end > end > > recurse_dir("/wherever/you/start") > > Eivind. Your code looks good, but it just loops... * trimmed.. *
.
.
.
file_map_2.rb:7:in `recurse_dir': stack level too deep (SystemStackError) from file_map_2.rb:11:in `recurse_dir' from file_map_2.rb:7:in `each' from file_map_2.rb:7:in `recurse_dir' from file_map_2.rb:11:in `recurse_dir' from file_map_2.rb:7:in `each' from file_map_2.rb:7:in `recurse_dir' from file_map_2.rb:11:in `recurse_dir' from file_map_2.rb:7:in `each' ... 2311 levels... from file_map_2.rb:11:in `recurse_dir' from file_map_2.rb:7:in `each' from file_map_2.rb:7:in `recurse_dir' from file_map_2.rb:19 Looks like it should work to me. I don't see how it can be infinite.