#!/usr/bin/ruby

require "open3"

path = "cvsroot"

tmpfn = "tmpfile_abcdefghijk"

com = "find #{path} -type f > " + tmpfn
system( com )

IO.foreach( tmpfn ) do |line|
  puts line
  com = "nkf -g " + line
  o, e, s = Open3.capture3( com )
  mojicode = o.chomp
  puts " Code of this file is " + mojicode + "."
  if mojicode != "BINARY" then
    com = "nkf -w --overwrite " + line
    system( com )
    puts " This file is converted."
    com = "nkf -g " + line
    o, e, s = Open3.capture3( com )
    mojicode = o.chomp
    puts " Code of this file is " + mojicode + ", now."
  end
end

com = "rm " + tmpfn
system( com )
