我在使用此代码时遇到了问题(再次)。
我试图让Ruby检查tree
是否等于$do_not_scan
中的任何项目,而我得到的只是{" cannot convert Array into String
& #34;错误。有什么方法可以解决这个问题吗?
我的代码:
#filesniffer by Touka, ©2015
$filecount = 0
$trees = Dir.entries("C:\\")
$do_not_scan = ["bootmgr", "BOOTNXT", "USER", ".", "Documents and Settings", "PerfLogs", "System Recovery", "System Volume Information", "$RECYCLE.BIN"]
def scan
$trees.each do |tree|
unless tree.include?($do_not_scan[0...8])
puts "scanning #{tree}"
entries = Dir.entries("c:\\#{tree}")
entries.each do |filename|
if filename == "**\*.dll"
puts "Found #{filename} in #{tree}"
end
end
end
end
end
def scan_loop
$trees.each do |tree|
scan
unless tree.include?($do_not_scan[0...8])
subtrees = Dir.entries("#{tree}")
subtrees.each do |tree|
scan
scan_loop
end
end
end
end
scan_loop
sleep
答案 0 :(得分:2)
以下内容必须在scan
和scan_loop
方法中进行更改:
$do_not_scan[0...8].include?(tree)
到位:
tree.include?($do_not_scan[0...8])