Do not rely on requiring "find". Cut-and-pasted the code instead.
This commit is contained in:
parent
8c8e111089
commit
4338b97351
@ -1,4 +1,45 @@
|
|||||||
require 'find'
|
# This is a copy of the code in the stdlib file 'find.rb'. GitHub doesn't seem
|
||||||
|
# to allow me to "require 'find'".
|
||||||
|
module Find
|
||||||
|
def find(*paths) # :yield: path
|
||||||
|
paths.collect!{|d| d.dup}
|
||||||
|
while file = paths.shift
|
||||||
|
catch(:prune) do
|
||||||
|
yield file.dup.taint
|
||||||
|
next unless File.exist? file
|
||||||
|
begin
|
||||||
|
if File.lstat(file).directory? then
|
||||||
|
d = Dir.open(file)
|
||||||
|
begin
|
||||||
|
for f in d
|
||||||
|
next if f == "." or f == ".."
|
||||||
|
if File::ALT_SEPARATOR and file =~ /^(?:[\/\\]|[A-Za-z]:[\/\\]?)$/ then
|
||||||
|
f = file + f
|
||||||
|
elsif file == "/" then
|
||||||
|
f = "/" + f
|
||||||
|
else
|
||||||
|
f = File.join(file, f)
|
||||||
|
end
|
||||||
|
paths.unshift f.untaint
|
||||||
|
end
|
||||||
|
ensure
|
||||||
|
d.close
|
||||||
|
end
|
||||||
|
end
|
||||||
|
rescue Errno::ENOENT, Errno::EACCES
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def prune
|
||||||
|
throw :prune
|
||||||
|
end
|
||||||
|
|
||||||
|
module_function :find, :prune
|
||||||
|
end
|
||||||
|
|
||||||
|
# ================================================================
|
||||||
|
|
||||||
def self.files_in(dir)
|
def self.files_in(dir)
|
||||||
files = []
|
files = []
|
||||||
|
Loading…
Reference in New Issue
Block a user