Class: Glynn::File

Inherits:
Object
  • Object
show all
Defined in:
lib/glynn/file.rb

Class Method Summary collapse

Class Method Details

.is_bin?(f) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
7
8
9
10
11
# File 'lib/glynn/file.rb', line 4

def self.is_bin?(f)
  file_test = %x(file #{f})

  # http://stackoverflow.com/a/8873922
  file_test = file_test.encode('UTF-16', 'UTF-8', :invalid => :replace, :replace => '').encode('UTF-8', 'UTF-16')

  file_test !~ /text/
end