#!/usr/bin/ruby def dump(d) Dir.entries(d).sort.each { |e| case e when '.', '..', 'index.html'; next end p = File.join(d, e) p = p[2..-1] if p[0, 2] == './' if File.file?(p) puts p File.chmod(0644, p) File.open('index.html', 'ab') { |fd| fd.puts " #{p}
" } elsif File.directory?(p) File.chmod(0755, p) dump(p) end } end ARGV << '.' if ARGV.empty? File.open('index.html', 'wb') { |fd| fd.puts "" } ARGV.each { |d| dump(d) } File.open('index.html', 'ab') { |fd| fd.puts "" }