Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/alt/ruby18/lib64/ruby/1.8
File: find.rb
#
[0] Fix | Delete
# find.rb: the Find module for processing all files under a given directory.
[1] Fix | Delete
#
[2] Fix | Delete
[3] Fix | Delete
#
[4] Fix | Delete
# The +Find+ module supports the top-down traversal of a set of file paths.
[5] Fix | Delete
#
[6] Fix | Delete
# For example, to total the size of all files under your home directory,
[7] Fix | Delete
# ignoring anything in a "dot" directory (e.g. $HOME/.ssh):
[8] Fix | Delete
#
[9] Fix | Delete
# require 'find'
[10] Fix | Delete
#
[11] Fix | Delete
# total_size = 0
[12] Fix | Delete
#
[13] Fix | Delete
# Find.find(ENV["HOME"]) do |path|
[14] Fix | Delete
# if FileTest.directory?(path)
[15] Fix | Delete
# if File.basename(path)[0] == ?.
[16] Fix | Delete
# Find.prune # Don't look any further into this directory.
[17] Fix | Delete
# else
[18] Fix | Delete
# next
[19] Fix | Delete
# end
[20] Fix | Delete
# else
[21] Fix | Delete
# total_size += FileTest.size(path)
[22] Fix | Delete
# end
[23] Fix | Delete
# end
[24] Fix | Delete
#
[25] Fix | Delete
module Find
[26] Fix | Delete
[27] Fix | Delete
#
[28] Fix | Delete
# Calls the associated block with the name of every file and directory listed
[29] Fix | Delete
# as arguments, then recursively on their subdirectories, and so on.
[30] Fix | Delete
#
[31] Fix | Delete
# See the +Find+ module documentation for an example.
[32] Fix | Delete
#
[33] Fix | Delete
def find(*paths) # :yield: path
[34] Fix | Delete
paths.collect!{|d| d.dup}
[35] Fix | Delete
while file = paths.shift
[36] Fix | Delete
catch(:prune) do
[37] Fix | Delete
yield file.dup.taint
[38] Fix | Delete
next unless File.exist? file
[39] Fix | Delete
begin
[40] Fix | Delete
if File.lstat(file).directory? then
[41] Fix | Delete
d = Dir.open(file)
[42] Fix | Delete
begin
[43] Fix | Delete
for f in d
[44] Fix | Delete
next if f == "." or f == ".."
[45] Fix | Delete
if File::ALT_SEPARATOR and file =~ /^(?:[\/\\]|[A-Za-z]:[\/\\]?)$/ then
[46] Fix | Delete
f = file + f
[47] Fix | Delete
elsif file == "/" then
[48] Fix | Delete
f = "/" + f
[49] Fix | Delete
else
[50] Fix | Delete
f = File.join(file, f)
[51] Fix | Delete
end
[52] Fix | Delete
paths.unshift f.untaint
[53] Fix | Delete
end
[54] Fix | Delete
ensure
[55] Fix | Delete
d.close
[56] Fix | Delete
end
[57] Fix | Delete
end
[58] Fix | Delete
rescue Errno::ENOENT, Errno::EACCES
[59] Fix | Delete
end
[60] Fix | Delete
end
[61] Fix | Delete
end
[62] Fix | Delete
end
[63] Fix | Delete
[64] Fix | Delete
#
[65] Fix | Delete
# Skips the current file or directory, restarting the loop with the next
[66] Fix | Delete
# entry. If the current file is a directory, that directory will not be
[67] Fix | Delete
# recursively entered. Meaningful only within the block associated with
[68] Fix | Delete
# Find::find.
[69] Fix | Delete
#
[70] Fix | Delete
# See the +Find+ module documentation for an example.
[71] Fix | Delete
#
[72] Fix | Delete
def prune
[73] Fix | Delete
throw :prune
[74] Fix | Delete
end
[75] Fix | Delete
[76] Fix | Delete
module_function :find, :prune
[77] Fix | Delete
end
[78] Fix | Delete
[79] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function