Class: Dir

Inherits:
Object show all
Defined in:
lib/rubyhacks.rb,
lib/rubyhacks.rb

Class Method Summary collapse

Class Method Details

.entries(dir = pwd, opts = {}) ⇒ Object



689
690
691
# File 'lib/rubyhacks.rb', line 689

def entries(dir=pwd,opts={})
	old_entries(dir,opts)
end

.recursive_entries(dirct = Dir.pwd, hidden = false, toplevel = true) ⇒ Object



779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
# File 'lib/rubyhacks.rb', line 779

def self.recursive_entries(dirct=Dir.pwd, hidden = false, toplevel=true)
	found = []
# 		ep Dir.pwd
# 		ep Dir.entries.find_all{|file| File.directory? file}
	chdir(dirct) do
# 			ep 'b'
		entries(dirct).each do |file|
# 				ep 'c'
			next if file =~ /^\./ and not hidden
			found.push file
# 				ep file
			next if [".", ".."].include? file
			if FileTest.directory?(file)
# 					ep file, Dir.pwd, File.expand_path(file)
				more = recursive_entries(File.expand_path(file), hidden, false)
				found = found + more
			end
		end
	end
	return toplevel ? found.map{|f| dirct + '/' + f} : found.map{|f| File.basename(dirct) + '/' + f}
end