@@ -332,7 +332,7 @@ def self.touch(filename)
332332 # 'lines'.
333333 #
334334 def self . wc ( filename , option = 'all' )
335- option . downcase!
335+ option = option . downcase
336336 valid = %w[ all bytes characters chars lines words ]
337337
338338 raise ArgumentError , "Invalid option: '#{ option } '" unless valid . include? ( option )
@@ -430,27 +430,27 @@ def self.bmp?(file)
430430 # Is the file a jpeg file?
431431 #
432432 def self . jpg? ( file )
433- File . read ( file , 10 , nil , :encoding => 'binary' ) == " \xFF \xD8 \xFF \xE0 \x00 \x10 JFIF" . force_encoding ( Encoding ::BINARY )
433+ File . read ( file , 10 , nil , :encoding => 'binary' ) == String . new ( " \377 \330 \377 \340 \000 \020 JFIF" ) . force_encoding ( Encoding ::BINARY )
434434 end
435435
436436 # Is the file a png file?
437437 #
438438 def self . png? ( file )
439- File . read ( file , 4 , nil , :encoding => 'binary' ) == " \x89 PNG" . force_encoding ( Encoding ::BINARY )
439+ File . read ( file , 4 , nil , :encoding => 'binary' ) == String . new ( " \211 PNG" ) . force_encoding ( Encoding ::BINARY )
440440 end
441441
442442 # Is the file a gif?
443443 #
444444 def self . gif? ( file )
445- %w[ GIF89a GIF97a ] . include? ( File . read ( file , 6 , nil , :encoding => 'binary' ) )
445+ %w[ GIF89a GIF97a ] . include? ( File . read ( file , 6 ) )
446446 end
447447
448448 # Is the file a tiff?
449449 #
450450 def self . tiff? ( file )
451451 return false if File . size ( file ) < 12
452452
453- bytes = File . read ( file , 4 , nil , :encoding => 'binary' )
453+ bytes = File . read ( file , 4 )
454454
455455 # II is Intel, MM is Motorola
456456 return false if bytes [ 0 ..1 ] != 'II' && bytes [ 0 ..1 ] != 'MM'
@@ -465,6 +465,6 @@ def self.tiff?(file)
465465 # Is the file an ico file?
466466 #
467467 def self . ico? ( file )
468- [ "\x00 \x00 \x01 \x00 " . force_encoding ( Encoding :: BINARY ) , "\x00 \x00 \x02 \x00 " . force_encoding ( Encoding :: BINARY ) ] . include? ( File . read ( file , 4 , nil , :encoding => 'binary' ) )
468+ [ "\000 \000 \001 \000 " , "\000 \000 \002 \000 " ] . include? ( File . read ( file , 4 , nil , :encoding => 'binary' ) )
469469 end
470470end
0 commit comments