Touka
Touka

Reputation: 11

Cannot convert Array into String (Ruby)

I'm having trouble with this code (again). I'm trying to get Ruby to check if tree is equal to any of the items in $do_not_scan and all I'm getting is a "cannot convert Array into String" error. Any way to fix such a thing?

My code:

#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

Upvotes: 0

Views: 136

Answers (1)

jon snow
jon snow

Reputation: 3072

It looks like the following have to change in the scan and scan_loop methods:

$do_not_scan[0...8].include?(tree) 

In place off:

tree.include?($do_not_scan[0...8])

Upvotes: 1

Related Questions