Created
June 29, 2015 10:37
-
-
Save msr1k/36e3f4bfe47437269ecd to your computer and use it in GitHub Desktop.
Check file format such as Windows(CR+LF), Xnix(LF), Mac(LF+CR) or something.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: cp932 | |
Dir.glob( "**/*" ) do |f| | |
next if FileTest.directory? f | |
next if [ | |
/^.git\// , /^RPC\// , /^Tools\// , /^TivaWare\// , /^.*~$/ , /^.*\.xlsx?$/ , /^.*\.docx?$/ , /^.*\.asta$/ , | |
/^.*\.mm$/ , /^.*\.md$/ , /^.*\.lib$/ , /^.*\.pp$/ , /^.*\.obj$/ , /^.*\.mk$/ , /^.*\.dat$/ , /^.*\.out$/ , | |
/^.*\.opt$/ , /^.*\.so$/ , /^.*\.dll$/ , /^.*\.exe$/ , /^.*\.bin$/ , /^.*\.xml$/ , /^.*\.png$/ | |
].detect{ |re| f =~ re } | |
File.open( f, 'rb' ) do |g| | |
g.binmode | |
r = g.read rescue :unknown | |
if r =~ /\r\n/ | |
if r =~ /[^\r]\n/ | |
puts "CR+NL & NL: #{f}" | |
else | |
puts "CR+NL : #{f}" | |
end | |
else | |
if r =~ /\r/ | |
puts "CR : #{f}" | |
elsif r =~ /\n\r/ | |
puts "NL+CR : #{f}" | |
elsif r == :unknown | |
puts "UN : #{f}" | |
else | |
puts "NL : #{f}" | |
end | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment