# Copycheck Script Written by Adam Nabinger
# Checks all appropriate code files for [filename] and "Copyright"

require 'find'

  Find.find(Dir.pwd) do |path|
    if FileTest.directory?(path)
      if File.basename(path)[0] == ?. or File.basename(path) == "bin" or File.basename(path) == "obj" then
        Find.prune
      else
        next
      end
    else
      if (File.extname(path) == ".cs" and not File.basename(path).include? ".Designer.") or File.extname(path) == ".script" or File.extname(path) == ".particle" then
        file = File.open(path)
        named = false
        copyright = false
        cornell = false
        5.times do
          line = file.gets
          break if line == nil
          line = line.chomp
          named = true if line.include? File.basename(path)
          copyright = true if line.include? "Copyright"
          cornell = true if line.include? "Cornell"
        end
        file.close()
        if not copyright or not named or not cornell then
          puts "Check " + (named ? "" : "[Name] ") + (copyright ? "" : "[Copyright] ") + (cornell ? "" : "[Cornell] ") + path
          #File.open(path) {|file| 5.times do puts file.gets.chomp end }
          system("pause")
        end
      end
    end
  end
  puts "Done."
  system("pause")